aspose file tools
The moose likes Java in General and the fly likes Rotating buffered image Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Rotating buffered image" Watch "Rotating buffered image" New topic
Author

Rotating buffered image

Ravi Kumar
Greenhorn

Joined: Oct 15, 2007
Posts: 16
Below is a simple program to rotate an buffered Image which is not working.

I'm create a small rectangle and rotating the entire graphic, which int urn should rotate the rectangle as well.
I'm lost, as to why it is not writing the rotated image. It writes the image which is not rotated.

I would appreciate any suggestions.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35252
    
    7
Have you tried doing the rotation before the drawing?


Android appsImageJ pluginsJava web charts
Ravi Kumar
Greenhorn

Joined: Oct 15, 2007
Posts: 16

Thanks for the quick response...It works !

How can i preserve the entire image. As the rotated image is big, the 90% of rectangle is out the the frame.
Is it okay if i create another bufferedImage of double the size and copy it ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Instead of doubling the size you should calculate the new width (and height!) using Math.cos, Math.sin and/or Math.tan. Although in this case it's a square that's rotated by 45 degrees so that makes the diagonal the width and height, and the diagonal is the width times the square root of 2 (1.4something; use Math.sqrt(2)).


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Ravi Kumar
Greenhorn

Joined: Oct 15, 2007
Posts: 16
Thank you for the idea. I will try that.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Rotating buffered image
 
Similar Threads
Image Coordinates and Scaling
image file rotation
rotate image java2d
Rotating a buffered image
Resetting or Undoing AffineTransforms