Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scale the image

 
Satyanarayana Murthy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic