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
posted
0
Have you tried doing the rotation before the drawing?
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 ?
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)).