File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Scale the image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Scale the image" Watch "Scale the image" New topic

Scale the image

Satyanarayana Murthy

Joined: Jul 30, 2003
Posts: 3
I have this problem, please provide me with some suggestions.
Imagine i have a rectangle of 374*378 and an image is loaded into that rectangle , now when a user clicks anywhere on that image , i will retrieve that point(upto this i am able to solve the problem).Now i have to make that point as center of the image and take the surrounding portion of the image and fit into the same rectangle. This is nothing but doing a zoomin depending on where the user clicks on that image.
I really appreciate any suggestions
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Well base your offset on the size of the display area. What I mean is, if they click on say 285,235 as an example, and your display area is 374 * 378, then base your offset off half your display area (i.e. 98... because 285 - (374 / 2) = 98) and the same for the height. That should set the image up so the point they clicked on ends up being in the middle.
Hrm... I'm not sure if I explained that right... well can't hurt to try this forum isn't very active.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
And if you want me to get specific about it (like with code) I need to know what you're using to display and manipulate the image. i.e. Swing, AWT, JAI? ImageIcon? PlanarImage? etc.
I agree. Here's the link:
subject: Scale the image
Similar Threads
rectangle from image
Need suggestions to count no of hits for Download link
To get the coordinates of mouse pointer...
Can't clear glassPane
Protection of images