• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scaled BufferedImage woes  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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,
randya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!