Zoom in/out into images

Hi mates ,
wanted to know if there is a method for zooming in/out to images or ill just have to implement it myself ?

lshaibin,
Use Graphics2D scale method in the paint method of your class that extends JPanel class.
example:
public void paint(Graphics g)
Graphics2D g2 = (Graphics2D)g;
// If you want some quality
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.scale(zoom,zoom);
g2.drawImage(image,0,0,null);
g2.dispose();
}

Similar Messages

  • What script for Zoom in/ out of image?

    1. I plan to import quite bigger bitmap image and save as a
    Graphic Symbol
    2. Make some Botton Symbols for +(Zoom in, -(Zoom out) and
    Reset.
    3. If I click +(Zoom in) button, image (reduced sized image
    in smaller window) got magnified.
    ----> What scripts do I need for this design? I'm working
    on Flash8.
    Thanks much in advance!!
    *** I got this idea from the site of
    http://www.metmuseum.org/explore/cezannes_apples/look.html
    And click "Let's Look Closely"...

    First of all, dont put your image as a graphic symbol ... use
    movieClip instead.
    Lets say you transform it into a movieClip and give it the
    instance "image" and that your zoom button is called zoomBtn and
    the un-zoom button is called unZoomBtn:
    //--> start the loop for zooming in on "press" event
    zoomBtn.onPress = function(){
    this.onEnterFrame = zoomIn;
    //--> start the loop for zooming out on "press" event
    unZoomBtn.onPress = function(){
    this.onEnterFrame = zoomOut;
    //--> stop the loop for zooming in or out on "release"
    event of both buttons
    zoomBtn.onRelease = unZoomBtn.onRelease = function(){
    delete this.onEnterFrame;
    //--> line of code executed in loop for the zoom in
    function zoomIn(){
    image._xscale = image._yscale += 5;
    //--> line of code executed in loop for zoom out
    function zoomOut(){
    image._xscale = image._yscale -= 5;
    }

  • PS CS5.1 - Changes/additions to doc don't appear until I zoom in/out of image

    Good evening,
    Over the past few weeks I've encountered a problem with Photoshop CS 5.1. Anytime I make an addition or alteration to an image (not a photo, but a digital composition) whatever I've done does not appear until I zoom in or out of the image. I have also tried waiting a few seconds to see if the program just lagged but it still doesn't appear until I zoom in or out. An example would be if I add text to a document, while I'm typing the cursor will move as I type but the text doesn't appear until I zoom. This is with solid text and of a color differing from the background.
    I tried increasing the memory available to the program (I have given it about 6gb), still occurs. I uninstalled and reinstalled the program, problem persists.
    I'm running Windows 7 64bit, Intel i7 1.6ghz, 8 gb of memory
    Any possible solutions would be very helpful. I've resorted to using CS2 and I would love to move back to CS5.
    Thanks

    Hi there! Because the forum you originally posted in is for beginners trying to learn the basics of Photoshop, I moved your question to the Photoshop General Discussion forum, where you'll get more specialized help.

  • Zoom In-Out Image

    Hi all,
    I want to apply the Zoom-In Zoom- Out feature on an Image .
    Can anyone help me ?.....
    Thanks

    Are trying SEARCH here?
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=resize&subCat=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&site=dev&dftab=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&chooseCat=javaall&col=developer-forums
    1) From SUN example
        private Image resize(Image image, int width, int height) {
            int sourceWidth = image.getWidth();
            int sourceHeight = image.getHeight();
            Image thumb = Image.createImage(width, height);
            Graphics g = thumb.getGraphics();
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x++) {
                    g.setClip(x, y, 1, 1);
                    int deltaX = x * sourceWidth / width;
                    int deltaY = y * sourceHeight / height;
                    g.drawImage(image, x - deltaX, y - deltaY, Graphics.LEFT | Graphics.TOP);
            Image immutableThumb = Image.createImage(thumb);
            return immutableThumb;
        }2: From this forum
    private int[] reescalaArray(int[] ini, int x, int y, int x2, int y2) {
       int out[] = new int[x2*y2];
       for (int yy = 0;  yy < y2; yy++) {
         int dy = yy * y / y2;
         for (int xx = 0; xx < x2; xx++) {
           int dx = xx * x / x2;
           out[(x2*yy)+xx]=ini[(x*dy)+dx];         }       }
       return out;}
    private Image getSmall(Image temp, int newX, int newY) throws Exception{
       //Need an array (for RGB, with the size of original image)
       int tX = temp.getWidth();
       int tY = temp.getHeight();
       int  rgb[] = new int[tX*tY];//Get the RGB array of image into  "rgb"
        temp.getRGB(rgb,0,tX,0,0,tX,tY);//Call to our function and obtain RGB2
        int rgb2[] = reescalaArray(rgb,tX,tY,newX,newY);//Create an image with that RGB array
        rgb = null;
        Image temp2 = Image.createRGBImage(rgb2,newX,newY,true);
        rgb2 = null;
        return temp2;
    }

  • Images I move from one folder into another are disappearing, at first it was occurring immediately if I did not copy and paste the images. Today however I found out that images I had been using for days just up and vanished from their new location.

    Images I move from one folder into another are disappearing, at first it was occurring immediately and only if I did not copy and paste the images. Today however I found out that images I had been using for days just up and vanished from their new location. A few of these images had copies in another folder that remained and the ones I couldn't find may or may not have ever had copies. I had backed up my system with time machine recently as well, so I went into the backup to retreive the lost images. When I searched and found the backup copies I got the error "the file alias cannot be opened because the original cannot be located". The crazy thing is that the images that remained on my computer did not give me the same error and opened like they should.
    In short images that I am creating, saving, and using are disapearing so epically that even time machine versions are affected when retrieval is attempted. Any suggestions as to what I could be doing wrong without realizing it? Or perhaps other people have had similar bugs that are software related and have a solution?

    Hi Kevin,
    I understand what you tried to do but it doesn't work that way. Swapping drive names will just mess things up.
    You should be able to reconnect the files though: in the Locate Referenced Files dialog make sure you click the Show Reconnect Options button — this will give you access to all the connected drives. Locate one of the files and hit Reconnect All. Should do the trick.
    Best

  • How to zoom in/out AND resize image?

    sorry if they are stupid questions but i can't seem to find how to resize and image and zoom in/out. I am using Version 3 of Photoshop Album Starter Edition.
    thanks in advance.

    Don't know what you want to do...
    Resize the actual image file? If so, PSA SE can't really do that.
    Just look at an image at different magnifications? Select image, F11 for full screen, then use CTRL/+ and CTRL/- to adjust.

  • How to (zoom in\out) on nokia e5 on images/photos

    how to (zoom in\out) on nokia e5 on images/photos ??
    I cant find zoom or any key to zoom any idea ??
    Solved!
    Go to Solution.

    Hello nour_esmat, did you try the volume buttons and the direction buttons? Try and reply.
    Nokia C7

  • Zoom in and zoom out a image in a java applet

    hello, i don't find any example of code of a java applet that zoom in and zoom out an image in jpeg format...
    can you help me?
    thanks

    Crosspost (and other thread has started some answers):
    http://forum.java.sun.com/thread.jspa?threadID=624295

  • E72 / Images - how to zoom in/out???

    Hi,
    Could not figure out how to zoom in/out when displaying an image in Media>Images... the usual */# do not seem to work here. And no clue in the provided help.
    Any ideas?
    Thanks!
    Rodolphe
    Solved!
    Go to Solution.

    Well done >

  • Zooming into image problems

    Hi everybody,
    I'm trying to learn how to zoom images, and I've been able to put together a test program; based on the posts I've seen on this forum (I didn't see anything about zooming in the Java tutorial), I thought it should be working, but it doesn't.
    My GUI consists of a JLabel with an icon on it, and a button panel beneath with zoom percentages. When I click on one of the zoom percentage buttons, the image is supposed to zoom in or out to that percent magnification, based on its original size (when the GUI is first created). When I click on the buttons in my test GUI, though, nothing happens to the image.
    EDIT: Oh, and I forgot to ask -- is zooming an established image like this the same as zooming a panel on which something has been painted? That's my eventual goal, but I thought it might be easier to learn with an established image first.
    Would anyone mind looking at my code, please, and giving me a hand?
    Thanks,
    Jezzica85
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.geom.AffineTransform;
    import java.io.File;
    import javax.imageio.ImageIO;
    import javax.swing.BorderFactory;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    public class ZoomTest extends JPanel {
         private static final long serialVersionUID = 1L;     // Serial ID
         private ImageIcon icon;                                        // Icon shown as picture
         private int zoomFactor;                                        // Factor of zoom (percent--ex 25=25%)
         // Constructor
         public ZoomTest() throws Exception {
              // Set initial zoom factor and read file
              zoomFactor = 100;
              String file = "C:\\test.bmp";
              icon = new ImageIcon( ImageIO.read( new File( file ) ) );
              JLabel label = new JLabel();
              label.setIcon( icon );
              // Add label with picture to scroll pane so zoomed image can be seen
              JScrollPane scroller = new JScrollPane( label );
              scroller.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
              scroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
              scroller.setBorder( BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) );
              scroller.setOpaque( true );
              scroller.setBackground( Color.WHITE );
              add( scroller );
         // Paint the image
         public void paintComponent( Graphics g ) {
              super.paintComponent( g );
            Graphics2D g2 = (Graphics2D)g;
            RenderingHints rh = new RenderingHints(
                 RenderingHints.KEY_ANTIALIASING,
                 RenderingHints.VALUE_ANTIALIAS_ON );
            g2.setRenderingHints( rh );
            AffineTransform at = new AffineTransform();
            AffineTransform initial = g2.getTransform();
            at.scale( zoomFactor, zoomFactor );
            g2.drawImage( icon.getImage(), at, this );
            g2.setTransform( initial );
         // Set the zoom factor for this panel
         public void setZoom( int factor ) { zoomFactor = factor; }
         // Main method for testing
         public static void main( String args[] ) {
              try {
                   // Add zoomable panel to frame
                   JFrame frame = new JFrame( "Zoom Test" );
                   frame.setLayout( new BorderLayout() );
                   final ZoomTest zoomer = new ZoomTest();
                   frame.add( zoomer );
                   // Add button panel with zoom levels
                   JPanel panel = new JPanel( new GridLayout( 1, 8 ) );
                   for( int i = 25; i <= 200; i+=25 ) {
                        final int amount = i;
                        JButton button = new JButton( Integer.toString( i ) );
                        button.addActionListener( new ActionListener() {
                             public void actionPerformed( ActionEvent e ) {
                                  zoomer.setZoom( amount );
                                  zoomer.repaint();
                        panel.add( button );
                   frame.add( panel, BorderLayout.SOUTH );
                   // Set Frame properties
                   frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                   frame.pack();
                   frame.setResizable( false );
                   frame.setAlwaysOnTop( true );
                   frame.setLocationRelativeTo( null );
                   frame.setVisible( true );
              catch( Exception e ) {
                   e.printStackTrace();
                   System.exit( -1 );
    }Edited by: jezzica85 on Dec 12, 2008 11:17 AM

    Since so many help me here, here is one solution
    package com.unittest.images;
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GraphicsConfiguration;
    import java.awt.GraphicsEnvironment;
    import java.awt.GridLayout;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import javax.imageio.ImageIO;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    * @author gcaulton
    public class Test extends JPanel {
              private static final long serialVersionUID = 1L;     // Serial ID
              private int zoomFactor = 100;                                        // Factor of zoom (percent--ex 25=25%)
              private BufferedImage zoomedImage = null;
              private BufferedImage originalImage = null;
              public Test() {
                   setOpaque(false);
              // Paint the image
              public void paintComponent( Graphics g ) {
                   super.paintComponent( g );
                 Graphics2D g2 = (Graphics2D)g;
                 g2.drawImage( zoomImage(), null, 0, 0);
              // Set the zoom factor for this panel
              public void setZoom( int factor ) {
                   zoomFactor = factor;
                   int newWidth = (int) (originalImage.getWidth() * zoomFactor /100.0);
                   int newHeight = (int) (originalImage.getHeight() * zoomFactor /100.0);
                   zoomedImage = resizeImage(originalImage, newWidth, newHeight);
              // Main method for testing
              public static void main( String args[] ) {
                   try {
                        // Add zoomable panel to frame
                        JFrame frame = new JFrame( "Zoom Test" );
                        frame.setLayout( new BorderLayout() );
                        final Test zoomer = new Test();
                        String file = "C:\\test.bmp";
                        zoomer.originalImage = ImageIO.read( new File( file ));
                        frame.getContentPane().setLayout(new BorderLayout());
                        frame.getContentPane().add( zoomer, BorderLayout.CENTER);
                        // Add button panel with zoom levels
                        JPanel panel = new JPanel( new GridLayout( 1, 8 ) );
                        for( int i = 25; i <= 200; i+=25 ) {
                             final int amount = i;
                             JButton button = new JButton( Integer.toString( i ) );
                             button.addActionListener( new ActionListener() {
                                  public void actionPerformed( ActionEvent e ) {
                                       zoomer.setZoom( amount );
                                       zoomer.repaint();
                             panel.add( button );
                        frame.add( panel, BorderLayout.SOUTH );
                        // Set Frame properties
                        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                        frame.setResizable( true );
                        frame.setAlwaysOnTop( true );
                        frame.setSize(zoomer.originalImage.getWidth(),zoomer.originalImage.getHeight()+200);
                        frame.setLocationRelativeTo( null );
                        frame.setVisible( true );
                        zoomer.setZoom(100);
                   catch( Exception e ) {
                        e.printStackTrace();
                        System.exit( -1 );
              private BufferedImage zoomImage() {
                   return zoomedImage;
              * @param image
              * @param newWidth
              * @param newHeight
              * @return
             public static BufferedImage resizeImage(BufferedImage image, int newWidth, int newHeight) {
                 if (image.getWidth() == newWidth && image.getHeight() == newHeight) {
                      return image;
                 } else {
                     BufferedImage temp = createCompatibleImage(image, newWidth, newHeight);
                     Graphics2D g2 = temp.createGraphics();
                     g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                     g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null);
                     g2.dispose();
                      return temp;
             public static BufferedImage createCompatibleImage(BufferedImage image, int width, int height) {
                  GraphicsConfiguration g = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
                 return g.createCompatibleImage(width, height, image.getTransparency());
    }

  • Flash Component: Image - crop, resize, rotate zoom in/out

    Hi, We've got a photo contest and we need an image
    manipulation tool that will allow users to import image, crop,
    move, resize, roate and zoom in/out to align their photo within a
    frame for example. Any one know of a component like this? I would
    appreciate and advice or links to other sites.
    Thanks in advance.
    Dan

    Don't know what you want to do...
    Resize the actual image file? If so, PSA SE can't really do that.
    Just look at an image at different magnifications? Select image, F11 for full screen, then use CTRL/+ and CTRL/- to adjust.

  • Best way to insert a table into image with high resolution for web?

    I've tried inserting a table from Excel into Photoshop and making a jpeg and gif out of it, but when I upload it to the web the resolution is terrible.
    Any ideas on how I can make get a table into an image? It's a bit too complex to create with HTML.

    Well, you are leaving out a lot of info.
    a: how are you saving it in Photoshop? What file type/compression amount, etc.
    b: how are you uplaoding it - where are you uploading it - are you uploading JUST the image, or are you uploading the image within an .html document?
    One thought, if you are JUST uploading it as an image, then trying to view it in a browser, if the image is larger than the viewport of the browser, some browsers will automatically rezie the image to fit visually into the viewport. More than likely, this resizing could be causing image distortion. Imagine it like when you zoom in/out in Photoshop - (unless you are using the accelerated graphic gui option in PS preferences), any zoom level outside of 25%, 50%, or 100% will cause visual distortion.
    Give a link to where you have uploaded the image (or whatever you are talking about). Like I said, there are other things to consider as to why this is happening.

  • 1:1 Zoom difference between similar images

    Hi   I have just upgraded to Lightroom 5 and am still figuring it out as I go.  
    I have recently been facing this baffling zoom problem.   For some reason when I zoom in 100% into an image it works just as it should. But when I zoom in to the next image which is exactly the subject shot in burst mode ...I actualy get a less than 100% zoom although on Navigator it says it is a 1:1 zoom. All my pictures have a combination of this contrasting zoom and I just can't figure out why? There seems to be no pattern!!!  
    Thanks  
    Preeti

    Yes I do.
    A friend suggested the following...to connect your hard drive, select all the images, discard the 1:1 preview and then discard the smart previews. Then Build the Smart Previews first followed by the 1:1 previews.
    I did that...
    I started out small, with a folder that had only 15 photos but still had this pesky problem. I did as was suggested and it worked perfectly for this folder.
    Then I thought I should try it out on a bigger folder with 318 photos before going all out. I did exactly as was suggested again. Everything was fine till it came time to building 1:1 previews. Instead of building 318 previews. It said it was building only 49!!!! And after that process as you can imagine the problem still persisted. So I tried again. This time I got 79 1:1 previews. And the last time I got 88. Thing is each time after the task is completed it says that 318 1:1 previews exist or were created.
    So I looked out for some of the problem photos and tried the discard preview - smart and 1:1 on them. I chose 9 such photos but only 1 or 2  1:1 previews were created. And then like magic it worked.  In a second group of photos it didn't work.
    I am now utterly and thoroughly confused.

  • Zoom- after initial zoom I want the image to return to original size

    After trying many different ways to zoom on one slide I have
    broken each zoom (of a selected image) out into 8 slides. I am
    wondering though... if I select the zoom to only last a few
    seconds, why does it continue to be 'zoomed' even after that time
    alloted has past?

    Hi bfair76 and welcome to our community
    Notice that the Zoom feature is typically configured for
    displaying the zoomed area for the slide duration. But you can
    easily change this. For example, I had a slide timed for 3 seconds.
    I inserted a zoom area and it zoomed for 1.5 seconds and stayed on
    the slide until the slide time ended at 3 seconds. I then increased
    the slide time to 5 seconds and the zoom followed suit. If you
    double-click the zoom object and click the Options tab, you may
    easily change the "Display for" area from "rest of slide" to
    "specific time", then configure the duration as desired.
    Hopefully this was helpful to you... Rick

  • Alt & scroll wheel not working on Photoshop CC to zoom in / out

    Hey! So i'm using the latest version of Photoshop CC, and i'm also running the Technical Preview of Windows 10. So In Photshop, usually when you hold the alt key and scroll with the scroll wheel on your mouse, it will zoom in / out of the image on Photoshop. Well i'm having some problems with that, it isn't working at all. In preferences I have it set to zoom with scroll wheel. Anyone know why it isn't working? Could it be something with the Windows 10 Preview?

    Please report Windows 10 issues to Microsoft, so they can get the information they need to fix the OS bugs before shipping the final version.

Maybe you are looking for

  • Recently I can no longer play music on my iPhone 5.  music is listed but just skips around.

    recently I can no longer play my music on my iphone 5.  Music is there but skips around if I try to play. does anyone know a fix?

  • Why is my on screen name not changing

    Hi all I logged in and changed my login name yesterday [email protected], this worked ok I also changed my on screen name, but it has not changed. I saved it and when i go into my account preferences it has changed, but it has not changed on the uppe

  • Problems with the setup of Adobe Digital Edition...Help!

    I just purchased an ebook, and I had followed all the steps towards viewing it. When I went to the setup screen for the digital edition, I put in my newly setup ID and password, selected "authorize computer", and pressed the activate button. When I d

  • Impact of reinstalling the SUP role at the Central server

    Hi Experts Env: 1 Central Server 15 Primary servers 1 WSUS Server Multiple Active update sources (all primary servers) We have identified an issue with multiple WSUS update sources in the database. This is from a previous WSUS installation where in t

  • Video Frames to Layers window issues

    hi im having this problem with the "File > Import > Video Frames to Layers" the box comes up like this: as you can see the box is white, the file i have imported if MP4 and iv tryed this with 2 files now, and get the smae thing, iv also tryed ans mov