Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

Zoom in , zoom out

Hello!
I have a web application and that take information from sql server database using jdbc.  Into a table I have an image field.
I want to show this image in a jsp page and then use zoom in and zoom out to see the image and print in original size.
Someone can help me please?
0
olgavillamizar
Asked:
olgavillamizar
  • 2
  • 2
1 Solution
 
colr__Commented:
To extract the image from the database you'll be best using a servlet instead of a jsp, as its all code with image output rather than text output (liek a jsp).

You would then put links on your jsp to the servlet like this: <img src="MyImageServlet?id=1" />. This willcall the servlet called MyImageServlet, passing the paramater 1. The servlet will return the image extracted from the database.

The zooming functionality is going to be a bit harder I think, cant help you with that sorry.

colr__
0
 
colr__Commented:
To zoom in and out you could change the height and width attribtes of the image html tag.

So when a user clicks to zoom, you post the user to the same page, but with a parameter that says "zoom this". Your jsp would thens et the height and width of the image accordingly.

colr__
0
 
rrzCommented:
colr  gave you a good start. Scaling can be done a number of ways  
java.awt.geom.AffineTransform  has   scale(double sx,double sy)  
or  
java.awt.Image   has  getScaledInstance(int width,int height,int hints)
Here is a method I had from before this.
     public static BufferedImage scale(BufferedImage bi){
         Image img = bi.getScaledInstance(100,-1,Image.SCALE_SMOOTH);
         int w = img.getWidth(null);
         int h = img.getHeight(null);
         BufferedImage scaled = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);          
         Graphics2D g = scaled.createGraphics();
         g.drawImage(img,0,0,null);
         if(g != null) g.dispose();
         return scaled;
     }  

Show us your code and we will help you with it.   rrz
0
 
rrzCommented:
Here is something else I saw on this forum. I didn't try it yet.
AffineTransform scale = AffineTransform.getScaleInstance(ratio, ratio);
BufferedImage scaled = new BufferedImage(60, (int)(h*ratio), BufferedImage.TYPE_INT_RGB);
Graphics2D g = scaled.createGraphics();
g.setTransform(scale);
g.drawImage(i, 0, 0, null);
if(g != null) g.dispose();
ImageIO.write(scaled, "JPG", thumbnailFile);
0
 
olgavillamizarAuthor Commented:
Im going to probe it and i´l tell you
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now