This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Rotating a buffered image  RSS feed

 
Alireza Bahmanpour
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wanted to write a method which gets a buffered image as parameter, rotates it 90 degrees clockwise around its top left corner, and then returns it. This method will be call from another method which then draws the rotated image on a rather large background which consists of many other images.

Here is the code I have so far


This method does rotate an image 90 degrees, but when the calling method recieves this image and displays it on the bigger frame, parts of the rotated image is cut. I think because the frame holding the returned image is not big enough. I've tried playing around with the code a lot, chaging the sizes of different images, and trying AffineTransform features, but I have had no luck.

I would greatly appreciate any help

Thanks in advance
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move this to our GUI forum.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Rotated Icon allows you to treat an Image like an Icon which gives it more flexibility as you can just draw the Icon or add the Icon to any Swing component that supports Icons. It will also handle non square Icons.

Or you can take a look at this example.
 
Carey Brown
Saloon Keeper
Posts: 2829
41
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about something like...

 
Prince Mathew
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swapping the values of 'w' and 'h' here will solve this problem. ie. No portion of the image will be lost.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!