How to zoom into a specific part of an image?

I am trying to mess around with2DGraphics and affinetramsform to zoom into a section of an image but i have no luck doing it. Can someone help me out? Lets say I want to zoom into the coordinates (200,300) and (400,600) . I know DrawImage has a method that does this but does 2DGraphics have it too or affinetransform? I havent see anything like it yet. thanks

you could check this
http://www.javareference.com/jrexamples/viewexample.jsp?id=84
it may help you

Similar Messages

  • How to have 2DGraphics zoom into a specific part of an image?

    I am trying to mess around with2DGraphics and affinetramsform to zoom into a section of an image but i have no luck doing it. Can someone help me out? Lets say I want to zoom into the coordinates (200,300) and (400,600) . I know DrawImage has a method that does this but does 2DGraphics have it too or affinetransform? I havent see anything like it yet. thanks

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ZoomIt extends JPanel {
        BufferedImage image;
        Dimension size;
        Rectangle clip;
        AffineTransform at = new AffineTransform();
        public ZoomIt(BufferedImage image) {
            this.image = image;
            size = new Dimension(image.getWidth(), image.getHeight());
            clip = new Rectangle(100,100,200,200);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.drawRenderedImage(image, at);
            g2.setColor(Color.red);
            g2.draw(clip);
            //g2.setPaint(Color.blue);
            //g2.draw(at.createTransformedShape(clip));
        public Dimension getPreferredSize() {
            return size;
        private void zoomToClip() {
            // Viewport size.
            Dimension viewSize = ((JViewport)getParent()).getExtentSize();
            // Component dimensions.
            int w = getWidth();
            int h = getHeight();
            // Scale the clip to fit the viewport.
            double xScale = (double)viewSize.width/clip.width;
            double yScale = (double)viewSize.height/clip.height;
            double scale = Math.min(xScale, yScale);
            at.setToScale(scale, scale);
            size.width = (int)(scale*size.width);
            size.height = (int)(scale*size.height);
            revalidate();
        private void reset() {
            at.setToIdentity();
            size.setSize(image.getWidth(), image.getHeight());
            revalidate();
        private JPanel getControlPanel() {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            panel.add(getZoomControls(), gbc);
            panel.add(getClipControls(), gbc);
            return panel;
        private JPanel getZoomControls() {
            final JButton zoom = new JButton("zoom");
            final JButton reset = new JButton("reset");
            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JButton button = (JButton)e.getSource();
                    if(button == zoom)
                        zoomToClip();
                    if(button == reset)
                        reset();
                    repaint();
            zoom.addActionListener(al);
            reset.addActionListener(al);
            JPanel panel = new JPanel();
            panel.add(zoom);
            panel.add(reset);
            return panel;
        private JPanel getClipControls() {
            int w = size.width;
            int h = size.height;
            SpinnerNumberModel xModel = new SpinnerNumberModel(100, 0, w/2, 1);
            final JSpinner xSpinner = new JSpinner(xModel);
            SpinnerNumberModel yModel = new SpinnerNumberModel(100, 0, h/2, 1);
            final JSpinner ySpinner = new JSpinner(yModel);
            SpinnerNumberModel wModel = new SpinnerNumberModel(200, 0, w, 1);
            final JSpinner wSpinner = new JSpinner(wModel);
            SpinnerNumberModel hModel = new SpinnerNumberModel(200, 0, h, 1);
            final JSpinner hSpinner = new JSpinner(hModel);
            ChangeListener cl = new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    JSpinner spinner = (JSpinner)e.getSource();
                    int value = ((Integer)spinner.getValue()).intValue();
                    if(spinner == xSpinner)
                        clip.x = value;
                    if(spinner == ySpinner)
                        clip.y = value;
                    if(spinner == wSpinner)
                        clip.width = value;
                    if(spinner == hSpinner)
                        clip.height = value;
                    repaint();
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            addComponents(new JLabel("x"),      xSpinner, panel, gbc, cl);
            addComponents(new JLabel("y"),      ySpinner, panel, gbc, cl);
            addComponents(new JLabel("width"),  wSpinner, panel, gbc, cl);
            addComponents(new JLabel("height"), hSpinner, panel, gbc, cl);
            return panel;
        private void addComponents(Component c1, JSpinner s, Container c,
                                   GridBagConstraints gbc, ChangeListener cl) {
            gbc.anchor = GridBagConstraints.EAST;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            c.add(s, gbc);
            s.addChangeListener(cl);
        public static void main(String[] args) throws IOException {
            String path = "images/owls.jpg";
            BufferedImage image = ImageIO.read(new File(path));
            ZoomIt test = new ZoomIt(image);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(test));
            f.getContentPane().add(test.getControlPanel(), "Last");
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • What's the easiest way to embed a video into a specific part of an image map?

    What's the easiest way to embed a video into a specific part of an image map?
    Anybody help? Is there a way to do this in Dreamweaver?

    One way would be to create your image map first. Then, use the CSS property position to position the div containing the video player relative to the image map or absolute to the page (depending on how your website layout is).
    Then, use an event listener (javascript) to enable the div holding the video player to show only when the specific area on the image map is clicked.

  • Hi my iph4s wont turn on or off and seems to be zoomed into a particular part of the screen, loads normally when rebooted the phone. what is wrong with it? and how would i go abouts fixing it?thanks

    hi my
    iph4s wont turn on or off and seems to be zoomed into a particular part of the screen, loads normally when rebooted the phone. what is wrong with it? and how would i go abouts fixing it?
    also recovery mode shows up as a red icon instead of a blue one, not jail broken or had any third party alterations
    thanks

    Reset the PRAM
    Reinstall the operating system from the dvd (you will not loose your data)

  • I am wondering how to zoom into a video in iMovie '09. For example I want to  zoom into a certain part of the video. Is there any way to do this???

    I am wondering how to zoom into a video in iMovie '09. For example I want to
    zoom into a certain part of the video. Is there any way to do this???

    Yes.
    If you want to see the zoom, use the Rotate, Crop, Ken Burns Tool and select the Ken Burns effect. You can set the starting and ending rectangle for your zoom.
    If you want to go directly to the zoom, use the Rotate, Crop, KenBurns Tool and select Crop. Set the rectangle to be where you want the zoom.

  • How do you cut out the part of an image in a photo?

    How do you cut out a part of an image on a photo that you have added to Pages. For example, if I have added a picture of a giraffe to Pages how would I cut out the giraffe from the image and get rid of the rest of the image

    You can use the instant alpha tool to make the background transparent.
    FYI: Pages is part of iWork, not iLife.

  • 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 into a specific point on a clip

    How do I zoom to a specific point on a clip or picture?
    Whenever I try to use this feature it just goes to the centre of the clip.
    Thank-you.

    Make sure Image + Wireframe is selected in the Canvas:
    Select the clip you want to zoom in on and reposition on the timeline by clicking on it. Once it is selected on the timeline, the turquoise box and cross hairs should appear in the canvas.
    If you click and drag on one of the boxes on the corner, you can resize your image:
    And if you click and drag on the image itself, you can change the clips position:
    You may need to change the canvas display scale to see the handles after you zoom in:
    MtD

  • How to zoom into small text in Title Edit Window?

    Ok,
    So when I am putting in disclaimer text in the Title edit window, I can't read it.  I could if I could zoom into it or at least increase the scaling of the video preview. 
    Someone else has had to have had this problem.  As you can see from the attached image, all the wasted extra space around the video, if I could just zoom in like you can on the preview window I could read it.
    How can I zoom into the area I am trying to edit with small text???
    Pleas help, anyone???

    First of all Reset Current workspace, does not seen to fit the window also I would make the titler a floating window.
    You cannot zoom in but you can make it full screen by hitting the 'tilde"(grave) key.
    You can also scale up the text, adjust, and scale it down again.

  • How to navigate to a specific part of a page using Navigation Model

    Hi....
    I need to navigate to a specific part of the page using navigation models.
    When I click on a link it should navigate to a div in the middle of the page instead of showing page from starting.
    How to achieve this using webcenter navigation models?
    Thanks.

    Hi All,
    Even I have the same requirement in my project.
    I need to navigate to a specific part of a page instead to the top of page using navigation models.
    I have a navigation model with name aboutUsNavigation.xml which have 5 links(About Us, Contact Us, Carrers, ...).
    I have used the adf tree Component to show the links.
    <af:tree id="about" var="node" initiallyExpanded="false" summary="AboutUs" value="#navigationContext.navigationMode
    l['modelPath=/oracle/webcenter/portalapp/navigations/aboutUsNavigation'].treeModel['includeStartNode=false']}" >
    <f:facet name="nodeStamp">
    <af:commandImageLink id="cil2" text="#{node.title}"
    actionListener="#{navigationContext.processAction}"
    action="pprnav"
    icon="#{node.attributes[pageFlowScope.tnBean.iconKey]}"
    disabled="#{not node.navigable}"
    inlineStyle="#{node.onSelectedPath ? 'font-weight:bold;' : ''}">
    <f:attribute name="node" value="#{node}"/>
    </af:commandImageLink>
    </f:facet>
    </af:tree>
    All the 5 links should navigate to the about.jspx. but each to a part of the page. how to achieve this?_
    Thanks..

  • How to INSERT INTO a specific row?

    I have a form with a calendar at the top, below it is a list of items each with a check box.
    Here is a wonderful visual of it -
    Calendar
    Checkbox | Col | Col | Col
    Checkbox | Col | Col | Col
    Checkbox | Col | Col | Col
    I want it so you select the date and it gets passed into the database in the same row as the one (definitely one, multiple is better) that has been checked by the user.
    I was trying an INSERT INTO with a WHERE statement but apparently you can't do that. So if I can use a WHERE with INSERT INTO, how can I identify which row to insert the info?
    Currently it is passing the dates but it creates a new row.
    I didn't think posting the code is neccisary for this question but if anyone wants to see it let me know and I will post it.
    THANKS!

    Ah, ok, I will try UPDATE.
    Right now my form looks like this...
    <cfform name="requestform" role="form"action="resources/requestform.cfm" method="post"  width="375" height="350" >
        <label for="startdate">Start Date:</label>
          <label for="enddate">Finish Date:</label>
        <cfcalendar name="selectedDate" 
            selectedDate="#Form.selectdate#"
            startRange="#Form.startdate#"
            endRange="#Form.enddate#" 
            mask="mmm dd, yyyy" 
            dayNames="SU,MO,TU,WE,TH,FR,SA"
            firstDayOfWeek="1"
            monthNames="JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC"
            style="rollOverColor:##FF0000"
            width="200" height="150">
                <cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#Form.startdate#">
                <cfinput type="dateField" name="enddate" label="End Date" width="100" value="#Form.enddate#">
        </div>
    <cfinclude
        template = "resources/query.cfm">
        <span class="label label-default">Equipment List</span>
        <table class="table table-bordered table-striped">
            <tr>
                <td><b>Select</b></td>   
                <td><b>Name</b></td>
                <td><b>Description</b></td>
                <td><b>Status</b></td>
            </tr>
        <cfloop query = "equiplist">
            <cfoutput>
            <tr>
                <td>
                    <cfinput name="status" type="checkbox" value="#serial#">Select:</cfinput>
                    <cfinput name="serial"type="text"style="display:none" value="#serial#">
                </td>   
                <td>#name#</td>
                <td>#descrip#</td>
                <td>#status#</td>
            </tr>
            </cfoutput>
    </cfloop>
    </table>
          <cfinput class="btn btn-default" type="Submit" value="Submit" name="addsubmit"></cfinput>
    </cfform>
    And the action page looks like this...
    <cfquery
            name = "requestform"
            dataSource = "db_cie">
            UPDATE equip
            SET STATUS="Out",
            WHERE serial='#status#'
    </cfquery>
    <cflocation
        url = "../request.cfm">
    But I am getting an error "invalid.user.table.column, table.column, or table specification. But the error message shows the SQL output and it looks correct...UPDATE equip SET STATUS="Out" WHERE serial="325255"... it IS getting the serial number variable passed from the form. ...No update though. Is my action form written wrong?

  • How to zoom into movieclip with double click and pan around?

    i found a tutorial to make a clickable map using timeline animations.
    i'd like to nest the original timeline into a movieclip and then allow users to double click to zoom in 200% and then double click again to zoom back to 100%. Id' also like to be able to pan around dragging while zoomed in.
    any tutorial link for this?

    lrosenth, Thanks for your reply!
    when I received the notification of AVPageViewDidChange
    How can I get the Scaling rate?

  • How to make specific parts of an image shake/vibrate in CS5?

    http://mothermonster.tumblr.com/post/2440088782/run-run-her-kiss-is-a-vampire-grin
    I'm trying to make something along the lines of the link above.
    Again, I'm new to Photoshop so I know this may be very easy to do.
    All help would be appreciated it.

    That's just an animated gif. Here's a tutorial on how to make them:
    http://creativetechs.com/tipsblog/build-animated-gifs-in-photoshop/

  • Organizer 12 - how to: zoom over 100%, use the Trackpad, compare images?

    English Version below.
    Hallo zusammen. Ich bin von Apple Aperture auf PSE 12 gewechselt. Nun habe ich meine 11500 Fotos im Organizer und ein paar Startschwierigkeiten.
    Ich habe in den Voreinstellungen angegeben, dass man Fotos auf über 100% skalieren darf. Das funktioniert aber nicht. Fotos werden immer nur im Fenster eingepasst, wenn der Zoomhebel ganz nach rechts steht.
    Einzig in der Vollbildansicht kann man über 100% skalieren. Dies funktioniert aber auch, wenn ich die Voreinstellung dazu nicht gesetzt habe.
    ie vergleiche ich mehrere Bilder? Im Handbuch steht beschrieben, dass man dazu aus dem Menü Ansicht -> Bilder Vergleichen wählen soll. Diesen Menüpunkt gibt es bei mir nicht.
    Auch bei dem Druck auf F12 geschieht bei mir nichts. Kann ich die Tastenfunktionen irgendwo neu zuweisen?
    Zu guter Letzt: kann ich die Zoom & Pinch Funktion des Magic Trackpads irgendwie einschalten? Das vermisse ich sehr. Da war Aperture sehr Bedienerfreundlich.
    English Version
    Hi there. I switched from Apple Aperture to PSE 12. Now I have my 11500 photos in the Organizer and a few teething problems.
    I have specified in the preferences that you can resize photos to over 100%. This does not work. Photos are always fitted only in the window when the zoom lever is all the way to the right.
    Only in the full-screen view you can scale over 100%. However, this also works if I have not set the setting in the preferences.
    How do I compare multiple images? The manual describes to select from the View menu -> Compare images. This menu item does not exist for me. (German Version)
    Also by pressing F12, nothing happens. Can I re-assign the button functions somewhere?
    Last but not least: How can I use the zoom & pinch from the Magic Trackpad? I 'm missing that very much. Aperture was very user friendly with that.

    You cannot zoom in on an more that fitting the screen space will looking at images in the Organizer's image well. This size may be much smaller than 100%.
    There is no preference to "resize photos to over 100%".
    There is also not a Compare option in the View menu.
    To do either of these options (from the Organizer) you have to be in the Full Screen mode. From here, you can use the mouse wheel (or trackpad) to zoom up to 1600%. You can also compare images by selecting the Side-by-Side or Top/Bottom display from the "View" Options button on the Full Screen options bar.
    To use the F-keys, you have to add the Command key, so Command+F12 will open the Full Screen Mode in side-by-side compare view.
    If you purchased Photoshop Elements as a replacement for Aperture, there are a lot of differences that you will have to adjust to. Photoshop Elements and Aperture are hardly complementary applications. If you were looking for something like Aperture, you should try Lightroom instead.

  • How to create a rollover as part of an image

    I want to create a background image with a button in the middle. I only want the button to act like a rollover. But when I create it in Fireworks only the slice is exported, not the rest of the image.

    A rollover consists of at least two images, some JavaScript code that recognizes when the mouse is over the image and swaps it for another, and the HTML to contain it all. Images are simple data files, they are not active code and they cannot contain links or rollovers, or anything like that.
    You need to export your background image separately from your button. Next, you need to export your button states. Then, you need to create a Web page where you set your background image as the background for an HTML element (maybe a div, maybe a table cell) and you place your button rollover inside the HTML element. (Dreamweaver would be really good for this.)
    You can't do it with just a single image.

Maybe you are looking for