Results 1 to 10 of 10
Thread: Rotating Buffered Image
- 09-29-2012, 05:26 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Rotating Buffered Image
Ok i've been searching on google for the past half hour looking for a way to rotate a buffered image by x amount of derees in a method that looks something like this
Java Code:public static BufferedImage rotate(BufferedImage a,int rotation) { return //the rotated BufferedImage }
- 09-29-2012, 05:34 PM #2
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Re: Rotating Buffered Image
i found this on the web but it cuts off some of the picture when rotated
Java Code:public static BufferedImage rotate(BufferedImage img, int rotation) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage newImage = new BufferedImage(width, height, img.getType()); Graphics2D g2 = newImage.createGraphics(); g2.rotate(Math.toRadians(rotation), w/2, h/2); g2.drawImage(img,null,0,0); return newImage; }
Last edited by jsobel; 09-29-2012 at 05:36 PM. Reason: Edit
- 09-29-2012, 06:05 PM #3
Re: Rotating Buffered Image
Moved from Advanced Java. Please take the effort to find a suitable section for your questions. Moreover, a simple application of available API can in no way be considered an advanced question.
Copying code (which may or may not be correct) and trying to use it without understanding it doesn't further your knowledge. Sketch out your original image and the 'rotated' newImage on paper and you should be immediately able to spot what's wrong.
But, where do the first two parameters to the constructor of newImage come from?
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 09-29-2012, 06:14 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Re: Rotating Buffered Image
I have an image i load into a class in the classes main method using the imageio class then i call the rotate method on it and then i save it to a file and part of the image is missing it has something to do with the size of the new image
- 09-30-2012, 06:00 PM #5
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
- 09-30-2012, 06:26 PM #6
- 11-13-2012, 12:32 AM #7
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Re: Rotating Buffered Image
yeah well even when i do that the image gets cut off because the graphics size doesn't change
- 11-13-2012, 05:18 AM #8
Re: Rotating Buffered Image
Graphics doesn't have a size.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 11-13-2012, 01:21 PM #9
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Re: Rotating Buffered Image
I dont know but when i rotate an image and put it into a larger image it still gets cut off
- 11-13-2012, 03:33 PM #10
Re: Rotating Buffered Image
To get better help sooner, post a SSCCE that clearly demonstrates your problem.
dbLast edited by DarrylBurke; 11-13-2012 at 03:39 PM.
If you're forever cleaning cobwebs, it's time to get rid of the spiders.
Similar Threads
-
Drawing on and rotating buffered Image
By NutterzUK in forum AWT / SwingReplies: 1Last Post: 12-09-2011, 05:55 AM -
Help with Image Rotating?
By Leospaceman in forum Java 2DReplies: 2Last Post: 05-31-2011, 03:48 PM -
Volatile image vs buffered image
By trishtren in forum Java 2DReplies: 0Last Post: 04-18-2011, 12:31 AM -
Rotating Buffered Image distorts image
By VortexSpin in forum Java 2DReplies: 1Last Post: 02-13-2011, 06:54 AM -
Rotating an image
By lackofcolor in forum Java 2DReplies: 3Last Post: 02-28-2009, 12:54 AM
Bookmarks