Image Coordinate

Hey,
I took screen shot of my whole screen and using locationonscreen i can get where the application i interested in locate at. but the problem is the image i took from the screen shot is need to be rescaled so the coordinate point inside that image will be different than the location onscreen point,
is there a way to find out what is the coordinate x and y become after rescaling? as oftenly i need to get the image of the application from that screen shot.
i believe there must some algorithm so we can calculate where the new coordinate will be.
i'm using Image.SCALE_SMOOTH.
thanks

You simply multiply the value of your x and y values by the scale factor used to scale the image.
matfud

Similar Messages

  • How to get Image Coordinates in a Frame

    Hi,
    I want to retrieve Image Coordinates contained in a Frame.
    I am able to get the frame coordinates through IGeometry but not the images.
    Any help will be highly appreciated.
    Regards,
    Rahul Rastogi

    Hi
    SnpGraphicHelper in SDK provides code for getting IImageDataAccess for given Frame ref. Use GetUID to get uid of the image from IImageDataAccess, obtained above.
    Once you get UID, you should be able to get its geometry.
    Rajani

  • Using mouse click to return image coordinates.

    Ok so I've been trying to figure out how to do this and it seems very complicated for something that really seems straightforward.
    Anyway. I have a camera that updates an image object on the front panel using a while loop. I have another image object that is updated with a still image when the "snap" button is pressed. Now what I want to do is to click on a point in the snapped image and have the VI return the coordinates of that pixel in the image coordinate frame.
    What I've got so far is an event structure in the while loop with the following to occur in the event "image object -> mouse down":
    Server reference (reference to the image object) -> Property node (last mouse position) -> output screen coordinates.
    I've got two errors that don't make a whole lot of sense to me (I haven't worked with event structures before): "event data node contains unwired or bad terminal" and "event structure one or more event cases have no events defined". This second one seems strange since I don't actually want anything to happen if there's no mouse click. The first one seems to refer to the element box on the left hand side of the event structure.
    The above is my lastest attmpt at sorting this problem and as far as I can see it should work. whatever about the errors, am I even taking the right approach with this? I'd have thought image cordinates would be a common enough thing but search the boards here, it would appear not...
    Kinda stumped here. Any help is much appreciated.
    Message Edited by RoBoTzRaWsUm on 04-14-2009 08:34 AM
    Solved!
    Go to Solution.

    Hello RoBoTzRaWsUm,
    I have taken a look at your VI, which has been taking a correct approach to the data you are looking for.  As you are using and event structure, you should be looking for an event to occur.  When using a Property Node, you are trying read an attribute of a control.  However, in an Event Structure, I believe you should be using an Invoke Node.  An Invoke Node allows your to read an event or write a method with the Control Class in LabVIEW. 
    1. Place down and Invoke Node from the Functions Palette in 'Programming'->'Application Control'
    2. Wire your Image Control reference to it
    3. Click Method, and select 'Get Last Event'
    4. Right click on 'Which Events' and 'Create Constant'.  Make the constant '1' in the array
    5. Read the 'Coordinates' Cluster from the left hand side of the Event Case by right clicking  and 'Create Indicator'
    You will find a piece of example code attached.
    Regards
    George T.
    Applications Engineering Specialist
    National Instruments UK and Ireland
    Attachments:
    UKSupportMouseClick.vi ‏39 KB

  • Image coordinates in JPanel

    Hi everyone,
    I need help in getting coordinates of a image that I have loaded in a JPanel using JFileChooser. The file is on my computer and that it can be any image. With the just loaded image, i have positioned it at 0,0 using the g.draw(). I will be dragging the image around the panel and I have seen some other people using certain methods to drag the image around the panel. Lets say the image img = null;
    I have tried img.getX(), img.getY() or
    img.getLocation.x, img.getLocation.y, or
    img.x, img.y or
    but the compiler give me "Cannot resolved symbol" for all the above methods or maybe some of the methods but the point is, none of the above methods work. Did miss out something or do i have to include some class or something?
    The reason i need to get the x,y for my image is to allow me to drag it around the panel. What i am looking for is to get the image coordinates x,y on the panel. As in the location of the image in the panel.
    Thanks in advance for the help.

    ... I have seen some other people
    using certain methods to drag the image around the
    panel. Have you asked them how they do it?
    Lets say the image img = null;
    I have tried img.getX(), img.getY() or
    img.getLocation.x, img.getLocation.y, or
    img.x, img.y or
    but the compiler give me "Cannot resolved symbol" for
    all the above methods or maybe some of the methods but
    the point is, none of the above methods work. Did miss
    out something or do i have to include some class or
    something?The something you're missing is the API. Make it your friend.
    >
    The reason i need to get the x,y for my image is to
    allow me to drag it around the panel. What i am
    looking for is to get the image coordinates x,y on the
    panel. As in the location of the image in the panel.There are two common ways to do this:
    1. Your custom panel directly drawing the image, so it has the job of knowing the image's position.
    Why not make imageX and imageY fields of your panel class?
    2. You custom panel class works like a Container, withe the image(s) being managed by a JLabel.
    Then your panel will use a null LayoutManager or perhaps will be a JLayeredPane and the JLabel's
    location is the location of the image.

  • How to set/get a portion of images coordinate

    i have one image(jpg file) and inside the image has mountain,house ,river
    how can i set mountain (X,Y) coordinate? if i click mountain , it will alert "this is a mountain"
    or if i mouse hover-over to river, it will alert "this is a river"? how to write a code using Flex api
    thank for help

    I think you can achieve this by using ImageMap component available in flexlib.
    http://flexlib.googlecode.com/svn/trunk/docs/flexlib/controls/ImageMap.html

  • Problem in getting the image coordinates  when i zoom in or zoom out

    Hi,
    i have doubts with scaling (Zoom in and Zoom out) using following code but when i zoom in want to get the x and y coordinates but im getting resized coordinates , pls do the needful
    public class TiffTest extends JFrame implements MouseListener
    public TiffTest(String filename)
    RenderedImage source= JAI.create("fileload",filename);
    SubsampleBinaryToGrayDescriptor sb=new SubsampleBinaryToGrayDescriptor();
    RenderingHints rh=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_DEFAULT);
    RenderedOp op=sb.create(source,new Float(0.5),new Float(0.5),rh);
    JScrollPane scrollPane = new JScrollPane();
    displayjai dj=new displayjai(op);
    scrollPane.setViewportView(dj);
    getContentPane().add(scrollPane,BorderLayout.CENTER);
    int screen_width=(int)this.getToolkit().getScreenSize().getWidth();
    int screen_height=(int)this.getToolkit().getScreenSize().getHeight();
    setVisible(true);
    setSize(screen_width,screen_height);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    dj.addMouseListener(this);
    JAI.create("filestore",dj.ima,"god.tif","TIFF");
    public static void main(String s[])
    new TiffTest("1_org.tif");
    public void mouseClicked(MouseEvent e){System.out.println(e.getX()+","+e.getY());}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseExited(MouseEvent e){}
    class displayjai extends DisplayJAI
    RenderedOp ima;
    public displayjai(RenderedOp inputImage)
    super(inputImage);
    ima=inputImage;
    setPreferredSize(new Dimension(ima.getWidth(),ima.getHeight()));
    System.out.println(inputImage.getWidth()+","+inputImage.getHeight());
    Thankx
    Kannan

    hi all,
    I am getting the image from the server.but the problem is i am getting the Exception as ArrayOutOfBound exception.
    It was displaying the Image for the first time.and when ever it was going for the second time in to the paint method it was displaying the IOException in reading the stream from the connection.
    can anybody give me the solution in rectifying that exception.
    thanks in advance
    lakshman

  • Image Coordinates and Scaling

    Hi,
    I'm creating and saving a BufferedImage with width and height 765. I'm then applying an scale AffineTransform of 3 on each axis.
    Then I'm attempting to draw a rectangle with x1, y1, coordiantes of 3, which scales to 9, and x2, y2 coordinates of 252, which scales to 756. However, the rectangle always seems to overlap the bottom right corner of the image and I have no idea why. Here is the code i'm using:
    public class SaveImage{
         //constructor
         public SaveImage() {
              //Load the variable
              // Create an image to save
             RenderedImage rendImage = myCreateImage();
             // Write generated image to a file
             try {
                 // Save as JPEG
                 File file = new File("thisTime.jpg");
                 ImageIO.write(rendImage, "jpg", file);
             } catch (IOException e) {
        // Returns a generated image.
        public static RenderedImage myCreateImage() {
            int imageWidth = 765;
            int imageHeight = 765;
            // Create a buffered image in which to draw
            BufferedImage bufferedImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
            // Create a graphics contents on the buffered image
            Graphics2D gr2D = bufferedImage.createGraphics();
            //Scaling to the appropriate size
            AffineTransform transformer = new AffineTransform();
             transformer.scale(3, 3);
             gr2D.setTransform(transformer);
            //A rectangle to give a white background
            gr2D.setColor(Color.white);
            gr2D.fillRect(0, 0, imageWidth, imageHeight);
            gr2D.setColor(Color.black);
            Rectangle2D rectangle = new Rectangle2D.Float(3, 3, 252, 252);
            gr2D.fill(rectangle);
            return bufferedImage;
    }Does anyone have any suggestions as to what I might be doing wrong?

    Check out this thread, the discussion there may answer your question.
    {color:#0000ff}http://forum.java.sun.com/thread.jspa?threadID=5276109{color}
    luck, db

  • Image Coordinates ?

    I have an image being displayed in a JPanel and would like to obtain coordinates from the image when a mouse click is pressed, and not the coordinates of the mouse device. How do I convert or obtain the actual coordinates/pixel of where the mouse was clicked on the image. (I already have a MouseListener)
    Thanks.

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.*;
    import javax.swing.*;
    public class ClickHere extends JComponent {
         public static void main(String[] args) throws IOException {
              JFrame f = new JFrame("click on the image");
              f.getContentPane().add(new JScrollPane(new ClickHere()));
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.pack();
              f.show();
         private BufferedImage image;
         private AffineTransform xform, inverse;
         public ClickHere() throws IOException {
              String url = "http://java.sun.com/people/jag/images/JamesWavingFlashlightInSydneyLo.jpeg";
              setBorder(BorderFactory.createTitledBorder(url.substring(1+url.lastIndexOf('/'))));
              image = ImageIO.read(new URL(url));
              if (image==null)
                   throw new IOException("woops");
              Insets insets = getInsets();
              xform = AffineTransform.getTranslateInstance(insets.left, insets.top);
              xform.scale(2,2);
              try {
                   inverse = xform.createInverse();
              } catch (NoninvertibleTransformException e) {
                   System.out.println(e);
              addMouseListener(new MouseAdapter(){
                   public void mousePressed(MouseEvent evt) {
                        System.out.println(inverse.transform(evt.getPoint(), null));
         public Dimension getPreferredSize() {
              Insets insets = getInsets();
              return new Dimension(insets.left + insets.right + 2*image.getWidth(),
                   insets.top + insets.bottom +  + 2*image.getHeight());
         protected void paintComponent(Graphics g) {
              super.paintComponent(g);
              ((Graphics2D) g).drawRenderedImage(image, xform);
    }Click on the window and the pixel coord will be printed to console. The original image is 150x177 and I show it doubled in scale and translated for the titled border. It is wrapped in a JScrollPane, so you can pan.
    Punchline: if all you are doing is translating and scaling, just do the math (which is what I should have done :-). If your case is more complicated (rotation?) use an inverse transform to convert from device space to user space.
    --Nax                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Exporting image coordinates and size

    I'd like to be able to export image position and percentage size for all pictures in a document (the purpose is to import this information into a database to facilitate autocreation of the douments later on), I've done this before for Quark files by processing the report files but InDesign doesn't have this information. I'm working with InDesign CS5 on OSX and have very little experience of AppleScript - I've had quite a good browse around but to no avail, any help would be greatly appreciated.

    Generating a report for images has been done hundreds of times before But of course, never exactly the way you want it to.
    This Javascript is based on one I wrote for a similar request; it only needed minor tinkering to fit your purpose.
    app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
    list = [];
    imgs = app.activeDocument.allGraphics;
    unitname = getCurrentUnit();
    for (i=0; i<imgs.length; i++)
    h = imgs[i].parent.geometricBounds[2] - imgs[i].parent.geometricBounds[0];
    w = imgs[i].parent.geometricBounds[3] - imgs[i].parent.geometricBounds[1];
    left = imgs[i].parent.geometricBounds[1];
    top = imgs[i].parent.geometricBounds[0];
    scale = roundMe(imgs[i].horizontalScale,1);
    // some fair rounding
    switch (unitname)
      case 'in':
       w = roundMe(w, 3);
       h = roundMe(h, 3);
       left = roundMe(left, 3);
       top = roundMe(top, 3);
       break;
      case 'cm':
       w = roundMe(w, 2);
       h = roundMe(h, 2);
       left = roundMe(left, 2);
       top = roundMe(top, 2);
       break;
      default:
       w = roundMe(w, 1);
       h = roundMe(h, 1);
       left = roundMe(left, 1);
       top = roundMe(top, 1);
    list.push (imgs[i].itemLink.name+'\t'+'('+left+','+top+')'+'\t'+w+' x '+h+' '+unitname+'\t'+scale+'%');
    // alert (list.join('\r')); exit();
    defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".txt");
    if (File.fs == "Windows")
    writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" );
    else
    writeFile = defaultFile.saveDlg( 'Save report');
    if (writeFile != null)
    if (writeFile.open("w"))
      writeFile.encoding = "utf8";
      writeFile.write (list.join("\r")+"\r");
      writeFile.close();
    function roundMe(val,to)
    var t = 1;
    while (to-- > 0) t *= 10;
    return Math.round(val*t)/t;
    function getCurrentUnit ()
    switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)
      case MeasurementUnits.POINTS: return "pt";
      case MeasurementUnits.PICAS: return "pt";
      case MeasurementUnits.INCHES: return "in";
      case MeasurementUnits.INCHES_DECIMAL: return "in";
      case MeasurementUnits.MILLIMETERS: return "mm";
      case MeasurementUnits.CENTIMETERS: return "cm";
      case MeasurementUnits.CICEROS: return "c";
      case MeasurementUnits.AGATES: return "ag";
      default: alert ("Oh, come on!"); exit(0);

  • Mouse clicks inside image in applet

    How can I respond to mouse clicks inside particular regions in an image loaded as part of an applet in a browser? ie, I want to send these clicks onto the server for the server to handle it and the server should change the image according to the mouse clicks.
    Thanks,

    /*  <applet code="ImageMouse" width="400" height="400"></applet>
    *  use: >appletviewer ImageMouse.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class ImageMouse extends JApplet
        JLabel label;
        public void init()
            ImageMousePanel panel = new ImageMousePanel();
            ImageMouser mouser = new ImageMouser(panel, this);
            panel.addMouseMotionListener(mouser);
            getContentPane().add(panel);
            getContentPane().add(getLabel(), "South");
        private JLabel getLabel()
            label = new JLabel(" ");
            label.setHorizontalAlignment(JLabel.CENTER);
            label.setBorder(BorderFactory.createTitledBorder("image coordinates"));
            Dimension d = label.getPreferredSize();
            d.height = 35;
            label.setPreferredSize(d);
            return label;
        public static void main(String[] args)
            JApplet applet = new ImageMouse();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(applet);
            f.setSize(400,400);
            f.setLocation(200,200);
            applet.init();
            f.setVisible(true);
    class ImageMousePanel extends JPanel
        BufferedImage image;
        Rectangle r;
        public ImageMousePanel()
            loadImage();
            r = new Rectangle(getPreferredSize());
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            int imageWidth = image.getWidth();
            int imageHeight = image.getHeight();
            r.x = (w - imageWidth)/2;
            r.y = (h - imageHeight)/2;
            g2.drawImage(image, r.x, r.y, this);
            //g2.setPaint(Color.red);
            //g2.draw(r);
        public Dimension getPreferredSize()
            return new Dimension(image.getWidth(), image.getHeight());
        private void loadImage()
            String s = "images/greathornedowl.jpg";
            try
                URL url = getClass().getResource(s);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
    class ImageMouser extends MouseMotionAdapter
        ImageMousePanel panel;
        ImageMouse applet;
        boolean outsideImage;
        public ImageMouser(ImageMousePanel imp, ImageMouse applet)
            panel = imp;
            this.applet = applet;
            outsideImage = true;
        public void mouseMoved(MouseEvent e)
            Point p = e.getPoint();
            if(panel.r.contains(p))
                int x = p.x - panel.r.x;
                int y = p.y - panel.r.y;
                applet.label.setText("x = " + x + "  y = " + y);
                if(outsideImage)
                    outsideImage = false;
            else if(!outsideImage)
                outsideImage = true;
                applet.label.setText("outside image");
    }

  • URGENT HELP plz! crop image

    I have an image
    when loaded into my program, i have the getScaledInstance to about half of the size
    and then i want to crop on that scaled image icon, how can i do that?
    i tried the crop image filter, but it always need to getImage().getSource() which require the cooridnates of the original image (non scaled one)
    i do not have the cooridnate of the original image, i just have the scaled image coordinate part for cropping. How can i crop?

    Hey, here's some code:
              URL url = getClass().getClassLoader().getResource("some_image.jpg");
              Image rawImage = ImageIO.read(url);
              Image bufferedImage = new BufferedImage(X, X, BufferedImage.TYPE_INT_ARGB);
              // Perform your scaling here.
              bufferedImage.getGraphics().drawImage(rawImage, 0, 0, X, X, X);
              MediaTracker tracker = new MediaTracker(this);
              tracker.addImage(bufferedImage, 1);
              tracker.waitForID(1);
              Image cropImage = bufferedImage.getSubimage(X, X, X, X);Is this anymore useful to you?
    Warm regards.

  • How to anchor zoom point in ScrollViewer+Image?

    I'm using the following XAML to allow the user to pan and zoom with an image:
    <ScrollViewer x:Name="scrollViewer" HorizontalSnapPointsType="None" HorizontalScrollBarVisibility="Auto" VerticalSnapPointsType="None" ZoomSnapPointsType="None" IsHorizontalRailEnabled="False" IsVerticalRailEnabled="False" ManipulationMode="All" VerticalScrollBarVisibility="Auto" ManipulationDelta="ScrollViewer_ManipulationDelta_1" IsDoubleTapEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False">
    <Image x:Name="pannableImage" Source="{Binding FullSizedImage}" ManipulationMode="All" Loaded="pannableImage_Loaded" IsDoubleTapEnabled="False" IsHitTestVisible="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Disabled" LayoutUpdated="pannableImage_LayoutUpdated">
    <Image.RenderTransform>
    <TransformGroup>
    <ScaleTransform x:Name="Scale" />
    <RotateTransform x:Name="Rotate" />
    <TranslateTransform x:Name="Translate" />
    </TransformGroup>
    </Image.RenderTransform>
    </Image>
    </ScrollViewer>
    What I want to be able to do is keep the starting point of the zoom in the same place on the screen as the user zooms in or out.
    In order to do that, I need to know the coordinates in the image where the zoom is starting so that I can then:
    Get the screen coordinates for the image coordinates before the new scale factor is applied.
    Get the screen coordinates for the image coordinates after the new scale factor is applied.
    Adjust the translate transform so that the position stays the same
    My problem lies in getting the point that the user is starting the zoom and then translating that into the underlying coordinates in the image.
    I've tried:
    private void scrollViewer_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
    Debug.WriteLine("scrollViewer_ManipulationStarted: position = {0},{1}", e.Position.X, e.Position.Y);
    GeneralTransform gt = pannableImage.TransformToVisual(scrollViewer);
    GeneralTransform gti = gt.Inverse;
    Point pt = gti.TransformPoint(e.Position);
    Debug.WriteLine("scrollViewer_ManipulationStarted: image pos = {0},{1}", pt.X, pt.Y);
    but the "image pos" numbers aren't right. It doesn't seem to matter if I pass scrollViewer or null to TransformToVisual.
    This is for a Windows Universal App so needs to work on both Windows 8.1 and Windows Phone 8.1.
    Can someone please advise a solution?
    Thanks.

    Hi Herro
    Thank you for suggesting that code sample. It certainly does support zooming in and out beneath the manipulation point.
    However, I am struggling to modify my existing implementation to support that different approach. There are a few areas where I'm having trouble and it may be that I just don't fully understand how the transforms work.
    When the image is loaded, I want to make sure that, initially at least, the image is scaled so that it fits onto the screen. I'm using various events to trigger that initialisation but the core of the code is this:
    double visibleHeight = Window.Current.Bounds.Height; // scrollViewer.ViewportHeight; //
    double visibleWidth = Window.Current.Bounds.Width; // scrollViewer.ViewportWidth; //
    // Get the image dimensions, allowing for rotation. We can be certain about
    // using the values of 0, 90, 180, 270 because the rotation is always done in
    // multiples of 90.
    double imageHeight, imageWidth;
    if (Math.Abs(selectedObject.Rotation) == 180 || selectedObject.Rotation == 0)
    imageHeight = ManipulateMe.ActualHeight;
    imageWidth = ManipulateMe.ActualWidth;
    else
    imageWidth = ManipulateMe.ActualHeight;
    imageHeight = ManipulateMe.ActualWidth;
    // If the image is larger than a screen dimension, work out
    // what factor we want to make that dimension fit.
    double scaleX, scaleY;
    if (imageWidth > visibleWidth)
    scaleX = visibleWidth / imageWidth;
    else
    scaleX = 1.0;
    if (imageHeight > visibleHeight)
    scaleY = visibleHeight / imageHeight;
    else
    scaleY = 1.0;
    // Pick the SMALLER of the scale factors so that we ensure both
    // dimensions fit onto the screen. Smaller because the values
    // should be less than 1, so the smaller the value, the more the
    // image is going to be reduced in size.
    double scale;
    if (scaleX < scaleY)
    scale = scaleX;
    else
    scale = scaleY;
    // Don't allow scale to be MORE than 1, at least initially. User can zoom in later.
    if (scale > 1.0)
    scale = 1.0;
    if (scale != 1.0)
    _compositeTransform.TranslateX = 0.0;
    double scaledHeight = imageHeight * scaleY;
    _compositeTransform.TranslateY = -(visibleHeight - scaledHeight) / 2;
    _compositeTransform.CenterX = ManipulateMe.ActualWidth / 2;
    _compositeTransform.CenterY = ManipulateMe.ActualHeight / 2;
    _compositeTransform.ScaleX = _compositeTransform.ScaleY = scale;
    Rect imageRect = _compositeTransform.TransformBounds(new Rect(0.0, 0.0, ManipulateMe.ActualWidth, ManipulateMe.ActualHeight));
    double visibleLeft = 0, visibleTop = 0;
    // Need to ensure that the image is positioned top-left
    if (imageRect.Left != visibleLeft)
    _compositeTransform.TranslateX = visibleLeft - imageRect.Left;
    if (imageRect.Top != visibleTop)
    _compositeTransform.TranslateY = visibleTop - imageRect.Top;
    Now, when the page loads and displays the image, the image is perfect - scaled and positioned just right. However, if I then try to move the image, it vanishes and debugging information shows that the coordinates of the image are all over the place.
    I *suspect* that the problem is being caused by my code setting up these initial values. My problem is that I don't know when to reset them or to what values.
    My next problem is to do with the panning. I want to ensure that the user doesn't lose the image, so I want to ensure that when the image is larger than the screen, the right hand edge of the image can be off to the right but cannot move more to the left
    than the right hand edge of the screen. Similarly for the other three sides of the image. My code works but it causes "bounces" in that the image seems to move back away from the screen edge and then back again to where I had "locked"
    the edge. Again, it may be because I need to reset a translation value but I just don't know when or what to.
    Below is my modified version of the ManipulationDelta routine:
    void ManipulateMe_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    if (forceManipulationsToEnd)
    e.Complete();
    return;
    _previousTransform.Matrix = _transformGroup.Value;
    Point center = _previousTransform.TransformPoint(new Point(e.Position.X, e.Position.Y));
    _compositeTransform.CenterX = center.X;
    _compositeTransform.CenterY = center.Y;
    // Reset rotation when user moves image around
    _compositeTransform.Rotation = 0;
    _compositeTransform.ScaleX = _compositeTransform.ScaleY = e.Delta.Scale;
    Rect imageRect = ManipulateMe.RenderTransform.TransformBounds(new Rect(0.0, 0.0, ManipulateMe.ActualWidth, ManipulateMe.ActualHeight));
    Debug.WriteLine("LTRB: {0},{1},{2},{3}", imageRect.Left, imageRect.Top, imageRect.Right, imageRect.Bottom);
    double visibleHeight = Window.Current.Bounds.Height; // scrollViewer.ViewportHeight; //
    double visibleWidth = Window.Current.Bounds.Width; // scrollViewer.ViewportWidth; //
    double visibleLeft = 0, visibleRight = visibleWidth, visibleTop = 0, visibleBottom = visibleHeight;
    double xAdjustment = e.Delta.Translation.X;
    double yAdjustment = e.Delta.Translation.Y;
    // If the image is SMALLER than the screen, don't let the edges of the image go beyond the screen edges
    // If the image is LARGER than the screen, make sure that the edges of the image are either all outside
    // the screen edges or stuck to the screen edges.
    if (imageRect.Width <= visibleWidth)
    Debug.WriteLine("... image is narrower than the screen");
    // Lock to the left hand side
    if ((imageRect.Left + xAdjustment) != visibleLeft)
    xAdjustment -= (imageRect.Left + xAdjustment - visibleLeft);
    else
    //Debug.WriteLine("... image is wider than the screen");
    if ((imageRect.Right + xAdjustment) < visibleRight)
    Debug.WriteLine("... stopping image from moving off the right edge");
    Debug.WriteLine("... right before adjustment = {0}", imageRect.Right);
    Debug.WriteLine("... adjustment is {0}", xAdjustment);
    Debug.WriteLine("... so potential new right is {0}", imageRect.Right + xAdjustment);
    xAdjustment = (visibleRight - imageRect.Right);
    Debug.WriteLine("... new adjustment is {0}", xAdjustment);
    Debug.WriteLine("... and new right is {0}", imageRect.Right + xAdjustment);
    if ((imageRect.Left + xAdjustment) > visibleLeft)
    Debug.WriteLine("... stopping image from moving off the left edge");
    Debug.WriteLine("... left before adjustment = {0}", imageRect.Left);
    Debug.WriteLine("... adjustment is {0}", xAdjustment);
    Debug.WriteLine("... so potential new left is {0}", imageRect.Left + xAdjustment);
    xAdjustment = (visibleLeft - imageRect.Left);
    Debug.WriteLine("... new adjustment is {0}", xAdjustment);
    Debug.WriteLine("... and new left is {0}", imageRect.Left + xAdjustment);
    if (imageRect.Height <= visibleHeight)
    Debug.WriteLine("... image is shorter than the screen");
    // Lock to the top
    if ((imageRect.Top + yAdjustment) != visibleTop)
    yAdjustment -= (imageRect.Top + yAdjustment - visibleTop);
    else
    //Debug.WriteLine("... image is taller than the screen");
    if ((imageRect.Bottom + yAdjustment) < visibleBottom)
    Debug.WriteLine("... stopping image from moving off the bottom edge");
    Debug.WriteLine("... bottom before adjustment = {0}", imageRect.Bottom);
    Debug.WriteLine("... adjustment is {0}", yAdjustment);
    Debug.WriteLine("... so potential new bottom is {0}", imageRect.Bottom + yAdjustment);
    yAdjustment = (visibleBottom - imageRect.Bottom);
    Debug.WriteLine("... new adjustment is {0}", yAdjustment);
    Debug.WriteLine("... and new bottom is {0}", imageRect.Bottom + yAdjustment);
    if ((imageRect.Top + yAdjustment) > visibleTop)
    Debug.WriteLine("... stopping image from moving off the top edge");
    Debug.WriteLine("... top before adjustment = {0}", imageRect.Top);
    Debug.WriteLine("... adjustment is {0}", yAdjustment);
    Debug.WriteLine("... so potential new top is {0}", imageRect.Top + yAdjustment);
    yAdjustment = (visibleTop - imageRect.Top);
    Debug.WriteLine("... new adjustment is {0}", yAdjustment);
    Debug.WriteLine("... and new top is {0}", imageRect.Top + yAdjustment);
    _compositeTransform.TranslateX = xAdjustment;
    _compositeTransform.TranslateY = yAdjustment;
    e.Handled = true;
    Many thanks for any suggestions you can make.
    Regards
    Philip

  • Smeared image when repainting

    I'm trying to recreate a game with a picture and when I move the image by changing the image coordinates and then using repaint()I get a "smeared" effect. Why is this, I've never had a problem when moving a 2D shape such as a circle or square? Thanks for the help

    You're not repainting over the old image data.
    Chances are you've overridden a paint/paintComponent method without calling super.

  • Image rotation - mapping the image into the center of the new image

            for (int x = 1; x < imageOne.getWidth()-1 ; x++) {
                for (int y = 1; y < imageOne.getHeight()-1 ; y++) {
                    /* Get the values from imageOne */
                    int red = imageOne.getRed(x, y);
                    int green = imageOne.getGreen(x, y);
                    int blue = imageOne.getBlue(x, y);
                             * x' = a0x + a1y + a2
                             * y' = b0x + b1y + b2
                    double x2 = Math.round(a0 * x + a1 * y);
                    double y2 = Math.round(b0 * x + b1 * y);
                    if (x2 > imageOne.getWidth()-1 || x2 < 0 || y2 < 0 || y2 > imageOne.getHeight()-1){
                        //Do Nothing
                    }else{
                        imageTwo.setRGB((int)x2, (int)y2, red, green, blue);
            }Using the above algorithm, the image will rotate, but the rotation will start from the corner of the image (coordinate 1,1). For example, if I do a >90 degree angle rotation, the image will diappear.
    I want my image to rotate and appear in the middle of the new image output.
    Any idea?

    Hi,
    As part of my courseowrk, where we can't use the Java's API, im trying ot do the rotation manually...
    Say my image is always 512x 512, and I've tried "translate" -> "rotate" -> "translate" below:
            for (int x = 1; x < imageOne.getWidth()-1 ; x++) {
                for (int y = 1; y < imageOne.getHeight()-1 ; y++) {
                    /* Get the values from imageOne */
                    int red = imageOne.getRed(x, y);
                    int green = imageOne.getGreen(x, y);
                    int blue = imageOne.getBlue(x, y);
                             * x' = a0x + a1y + a2
                             * y' = b0x + b1y + b2
                    //1st transform
                    x2 = x+256;
                    y2 = y+256;
                     double rad = Math.toRadians(m);
            double cos = Math.cos(rad);
            double sin = Math.sin(rad);
            int newX = (int)Math.round(cos * getX() - sin * getY());
            int newY = (int)Math.round(sin * getX() + cos * getY());
            setX(newX);
            setY(newY);
                    //2nd transform
                    x2 = x2-256;
                    y2=y2-256;
                    if (x2 > imageOne.getWidth()-1 || x2 < 0 || y2 < 0 || y2 > imageOne.getHeight()-1){
                        //Do Nothing
                    }else{
                        imageTwo.setRGB((int)x2, (int)y2, red, green, blue);
            }setX and setY will update the value in x2 and y2.
    The concept is to move the pointer to the mid of the image (midHeight and midWidth) which is "x2 = x+256;" and "y2 = y+256;", rotate and translate again - but the output is still nto in the middle..
    Any idea?

  • How can we get an image of selected area of the front panel

    i am plotting some graphs and want a group photo of all those in one shot is it possible????
    n i want to get the graph coordinates on the mouse click.....
    i.e when i click on the graph at any place the values corresponding to it must be retrieved. how do we do that,,...
    i have tried with the labview help but didnt get any help
    help please????????

    Here's a start.  This will get the front panel image and display it as a picture indicator.
    You could use an event structure to capture the mouse clicks on the picture control to set the image area.  Then using the mouse coordinates (referenced from the image coordinates), you can get the image subset "Get Image Subset.vi".
    Message Edited by vt92 on 04-20-2010 08:30 AM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal

Maybe you are looking for

  • Nokia Drive on Windows Phone- the future. What can...

    Hi Everyone, The question is obviously pointed towards Nokia representatives here, but we're all probably interested in, more or less. So: What can we expect from Nokia Drive (and Maps...) in future? Are we gonna be given back at least the basic func

  • Printing Payment Advice

    Hi all, Please let me know how to take print outs of Payment Advices. I was trying transaction FBE1 to create payment advices. But the print option is to available here. Also pls let me know how to do Payment advices for F110 also. Thanks & Regards,

  • Accepting Exchange 2010 Appointments with Outlook

    Accepting outlook appointment shows as accepted in outlook, but if iphone and ipad connect to the same exchange account it doesn't show up as accepted on the iphone. It does show as accepted on the iPad. If only the iphone is connected to the same ex

  • System error 3 OracleDBConsoleorcl service could not be started.

    Hallo!I installed Oracle 10g on my Windows XP while connected to my modem that accesses the internet via DHCP. I installed the Microsoft Loopback Adapter to force my OEM and isqlplus to use the static IP 10.0.0.1. When I try to launch my OEM via http

  • User tried to grant quota on an undo or temporary tablespace

    Hi. I got this error (see below). Question - did it happen because one cannot grant a quota on a temp TS or because I ran the ALTER USER as a user with DBA role and not as SYS? Thanks, Error starting at line 14 in command: ALTER USER IM_DBA QUOTA UNL