Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problems to rotate rectangular images

807606Jun 4 2007 — edited Jun 5 2007
Hello,

I wrote code to rotate BMP images, and it works very good with square images. But it doesn't work with rectangular ones. When I try to rotate them, I obtain an images with all pixels in a wrong position, so that it is impossible to understand the content... WHY ??
thank you
				//BufferedImage toStore
				BufferedImage toStore = new BufferedImage(Width,Height,BufferedImage.TYPE_INT_RGB );
				Graphics2D g2d =toStore.createGraphics();
				

				
				//double centerX = (Height - Width)/2.0;
			    //double centerY = (Width - Height)/2.0;
				
				double centerX = Width/2.0;
			    double centerY = Height/2.0;
			    
			    AffineTransform rotationTransform = new AffineTransform();
			    	
			    rotationTransform.rotate(Math.toRadians(Degrees), Width/2.0, Height/2.0);
				
				
				
			    // draw the image using the AffineTransform
				g2d.drawImage(img, rotationTransform, null); 
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2007
Added on Jun 4 2007
5 comments
51 views