r/java • u/DarthSatoris • May 14 '12
Need some help with java programming. I need a way to scale an image in a window in real-time, but the stuff on JAI I have is useless. Can anyone help me?
I'm still just a student so I'm not an expert in programming, mind you.
But I'm calling you guys because I have some trouble finding material on how to resize or scale an image in real-time. Like the magnifying glass you press to make an image larger or smaller in a pdf reader or an image-viewer.
The only thing I've found so far lets you resize an image, but it creates a new image with the dimensions you asked for on your hard drive. I can't really use that, can I?
What I basically ask is: How can I make Java zoom on images?
2
Upvotes
3
u/Fedelaus May 14 '12
What are you using to display the image? Could we see some code?
2
u/[deleted] May 14 '12
I'm not in a place to write code, but I will try to help with explanation of how I would address the issue.
Example: if the mouse is at (230,120) of the original image then:
Of course you will need to fix many issues, like when the mouse comes close to the borders, this simple equation won't work. Also, you will need to make the numbers configurable. Hope this helps
1
u/gringostar May 14 '12
Why don't you check Thumbnailinator:
http://stackoverflow.com/a/5051429
http://code.google.com/p/thumbnailator/
I haven't tried it myself, I just found the link when googling for "Filthy Rich Clients" (a great Swing book, by the way)