This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Horizontal flip  RSS feed

 
Edward Nunez
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's a simple way to flip an Image along the vertical or horizontal? I've searched high and low and surprised to find that I can't find something short and compact.

Thanks,
Edward.
 
Jhonson Fernando
MyExamCloud Software Support
Ranch Hand
Posts: 692
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use trigonometry to determine the correct width/height, using transparency to prevent the black area.

 
Edward Nunez
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Koilraj but I think you may have misinterpreted the question. I was looking for a way to mirror an image.
 
Ishan Verma
Greenhorn
Posts: 4
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Following code contains a function that will take a BufferedImage and return a BufferedImage that is horizontally flipped:



If you are looking at vertically flipping an image, checkout the snippet below:



Hope this helps.
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is some old code I found on the web a long time ago. It works for an Icon. It should also work for an image but I have never tested it:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!