aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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)
 
Similar Threads
Image in JFrame ???
Problem Updating a JButton
'Stale' image reference is retained by JFrame desktop app--latest image won't display
getImageIcon() : how does it work?
Click a button to display an image. Trouble with add panel to a frame. Help !!