Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Rotation ??

Status
Not open for further replies.

DannyB

Programmer
Mar 19, 2000
99
PT


How could I rotate an image, then save it (so it stays rotated). I can rotate it (but its just a visual effect).
 
You have 3 choice depending on what JDK you are using.

In all cases you will need to create a BufferedImage and write to it's Graphics2D obect. Once you have that.

If you are using JDK 1.2 or 1.3 it is more difficult. You will need to look at the com.sun.image.codec.jpeg package.
After you look at that you will want to focus on two classes JPEGImageEncoder, and JPEGEncodeParam. Plus you will need a ByteArrayOutputSteam, and a FileOutputStream.

Next, if you have JDK 1.4 you can do what I think is the easest method. You will need to look at the javax.imageio package. All you need from there is the ImageIO class. it has a write method that takes a RenderedImage (which is what a BufferedImage is), you give it the formate type (example "jpg" "gif") and a OutputStream. Your done.

The last way is with Sun's Advanced Imaging API. This one is similar to the first one in how you do it. The problem is that it is a external library not part of the J2SE. You would have to download this from Sun, and then look at the javax.imageio package. Focus on the ImageEncoder and JPEGEncodeParam classes. You will need a FileOutputStream here as well.

I recommend the 2nd way using JDK 1.4 if you are or can use this JDK great.

I hope this helps...

Rodney
 
It did thanks.

JDK 1.4 isn't an option unfortunatelly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top