• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Scale a BufferedImage. (Solved)

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic