• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Himai Minh

Scaled BufferedImage woes

Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, here's a tuffy:
At work I'm creating an app that displays binary data on a raster display. I am using a BufferedImage to store the raster that I create by hand using information from a byte array (the format of the data and how it is processed is unimportant to the question).
Since the user will be looking at data that are represented by a single pixel, I thought it would be nice to have a 1x, 2x, 4x zoom option to "blow up" the data (e.g., at 4x one pixel is rendered as a 4x4 sqaure). To do this, I am using Image.getScaledInstance() to increase/decrease the size of the image over the same amount of JPanel real-estate.
Okay, here's the problem/question: The JPanel I display the image on is scrolled by a JScrollPane. When the zoom factor is 1x (i.e., no zoom), the scrollbars work correctly. However, when I apply a 2x or 4x zoom, the scrollbars still believe the image size is 1x resulting in the inability to display part of the image.
So how do I tell the scrollbars that the image is now two or four times the actual size of the original? I've tried JScrollPane.setViewport() and JScrollPane.setViewportView(), but they seem to only send a repaint() after validating the JScrollPane. Any ideas?
Sorry no code, but I think the question is abstract enough to respond without it. If you REALLY want to see it, let me know and I'll drag it up.
Thanks folks,
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic