• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding working on images using Java

 
Satyanarayana Murthy
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
I have to develop a program which loads an image to Jpanel, and then draws a line using two points.After that when a user click on the image it should be able to zoon in/out.
I am new to java Swing and graphics stuff , i am planning to learn and do this , I really need some suggestion from where to start .I think i have to use java 2d API.I got little bit idea of how to draw a line on image,but i am blank anout how to zoom in /out.
I really appreciate any suggestions ,as this is part of my job atleast i want to know from where i should start.
Thank you
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing forum.
 
Michael Phospere
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a BufferedImage (subclasses Image), you can:
1) Call BufferedImage.createGraphics() to get the Graphics context (as a Graphics2D object) for the image.
2) Use Graphics2D.drawXXX to draw whatever you want onto your image.
 
Michael Phospere
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mah bad. I didn't read
To simulate zoom in/zoom, I'm guessing you can use BufferedImage.getSubImage() to get the portion of the image you want to zoom in on, then use BufferedImage.getScaledInstance() to scale it back to the full size of the viewing window.
Just a guess, seems like it could work.
 
Satyanarayana Murthy
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you michel , but i am still not fully satisfied , anyway i will go and read about all that .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic