File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Scale a BufferedImage.   (Solved) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Scale a BufferedImage.   (Solved)" Watch "Scale a BufferedImage.   (Solved)" New topic
Author

Scale a BufferedImage. (Solved)

Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
I have created a buffered image
Then I construct my GUI as a frame with three panels. The one on which the image is to be displayed is coded:
The image I'm working with is big, 4004 pixels by 2762 lines, and all that displays is the upper right hand corner. I want to scale it by a factor of 1/3 to fit on my display before displaying it.
I've looked at couple of APIs but I'm new at this and I'm missing something and I don't know how to use the hash table in this context.

Edit
It took a lot of searching and trials but I found a way by creating a class that extends JPanel and putting the code in it;

In my GUI setup:

It all appears to work now (at least to scale an image down) and I can retrieve the pixel values (16 bit gray scale) under the tool tip from the original data.
Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
The above works but is not quite correct if one wants to print or save the image. I found the save image had the reduced size image in the upper right corner of the original image! Here's corrected code.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scale a BufferedImage. (Solved)