Bitmap Rotation According to Mouse Position?

Hi,
I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
for example: 

Hi,
I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
for example: 
Hello,
To rotate that image, we need to deal with the following tips.
1. The image size.
If the area for that image rotated is not big enough, it will just lose some parts of that image.
Here is a nice code shared in this thread
http://stackoverflow.com/questions/5199205/how-do-i-rotate-image-then-move-to-the-top-left-0-0-without-cutting-off-the-imag/5200280#5200280.
private Bitmap RotateImage(Bitmap b, float Angle)
// The original bitmap needs to be drawn onto a new bitmap which will probably be bigger
// because the corners of the original will move outside the original rectangle.
// An easy way (OK slightly 'brute force') is to calculate the new bounding box is to calculate the positions of the
// corners after rotation and get the difference between the maximum and minimum x and y coordinates.
float wOver2 = b.Width / 2.0f;
float hOver2 = b.Height / 2.0f;
float radians = -(float)(Angle / 180.0 * Math.PI);
// Get the coordinates of the corners, taking the origin to be the centre of the bitmap.
PointF[] corners = new PointF[]{
new PointF(-wOver2, -hOver2),
new PointF(+wOver2, -hOver2),
new PointF(+wOver2, +hOver2),
new PointF(-wOver2, +hOver2)
for (int i = 0; i < 4; i++)
PointF p = corners[i];
PointF newP = new PointF((float)(p.X * Math.Cos(radians) - p.Y * Math.Sin(radians)), (float)(p.X * Math.Sin(radians) + p.Y * Math.Cos(radians)));
corners[i] = newP;
// Find the min and max x and y coordinates.
float minX = corners[0].X;
float maxX = minX;
float minY = corners[0].Y;
float maxY = minY;
for (int i = 1; i < 4; i++)
PointF p = corners[i];
minX = Math.Min(minX, p.X);
maxX = Math.Max(maxX, p.X);
minY = Math.Min(minY, p.Y);
maxY = Math.Max(maxY, p.Y);
// Get the size of the new bitmap.
SizeF newSize = new SizeF(maxX - minX, maxY - minY);
// ...and create it.
Bitmap returnBitmap = new Bitmap((int)Math.Ceiling(newSize.Width), (int)Math.Ceiling(newSize.Height));
// Now draw the old bitmap on it.
using (Graphics g = Graphics.FromImage(returnBitmap))
g.TranslateTransform(newSize.Width / 2.0f, newSize.Height / 2.0f);
g.RotateTransform(Angle);
g.TranslateTransform(-b.Width / 2.0f, -b.Height / 2.0f);
g.DrawImage(b, 0, 0);
return returnBitmap;
2. The location of that control which displays that image.
If we use a picturebox, and set its sizemode to autosize like the following line, then if you just want to rotate that image to show, and you don't want to that affects the original image, then we need to keep its center point.
this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
We could add resize event handler after we set image for that picturebox.
        Point pOrign;
        Size sOrign;private void Form1_Load(object sender, EventArgs e)
this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
Image img = Image.FromFile(@"D:\Documents\New folder\New folder\TestImage.PNG");
this.pictureBox1.Image = img;
this.pictureBox1.InitialImage = img;
pOrign = new Point(this.pictureBox1.Left , this.pictureBox1.Top );
sOrign = new Size(this.pictureBox1.Width, this.pictureBox1.Height);
this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
this.pictureBox1.Resize += pictureBox1_Resize;
private void pictureBox1_Resize(object sender, EventArgs e)
this.pictureBox1.Left = this.pOrign.X + (this.sOrign.Width - this.pictureBox1.Width) / 2;
this.pictureBox1.Top = this.pOrign.Y + (this.sOrign.Height - this.pictureBox1.Height) / 2;
3. The angle between that center point and your mouse postion.
We could get that value inside the picturebox's container's mouse_move event.
Double angleNew ; private void pictureBoxContainer_MouseMove(object sender, MouseEventArgs e)
angleNew = Math.Atan2(this.pOrign.Y + this.sOrign.Height / 2 - e.Y, this.pOrign.X + this.sOrign.Width/2 - e.X) * 180.0 / Math.PI;
But when to start rotate that image, it should be your chooice, and you could decide when rotate that image with the following line.
this.pictureBox1.Image = (Image)RotateImage(new Bitmap(this.pictureBox1.InitialImage), (float)angleNew);
If you just want to save that change to that image, then you could save that bitmap to file directly.
Happy new year.
Regards.
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to get an Image to rotate according to the position of the mouse in Muse?

    Hey guys,
             I'm designing a home page that is centered around a logo. I need the logo to rotate around 360 degrees as the mouse explores the area around it. I'm attaching a quick sketch explaining the type of motion I need, a mockup of what the page might look like, and a .png file I'll be using for the logo. Please give detailed instructions, as I am somewhat new to Muse. Thanks in advance, any help is MUCH appreciated!

    UPDATE: The movement can be made very simply in Adobe Edge Animate through the following process:
    (and then published as an Animate Deployment Package and inserted into Muse as a .oam file.)
    "   Based on this stack exchange response Edit fiddle - JSFiddle
    Place the provided script in compositionReady and change the var img reference to the name of your element.
    example: var img = sym.$("WirelosLogoTight");     "
    - Heathrowe
      Hope this helps anyone else with the same question. Here is a link to that post: How to create an animation that rotates in response to the mouse position?

  • Rotate matrix by mouse position.

    Hey guys I have been banging my head against this problem for the past few hours.  I have a rectangle object created, I want the rectangle's rotation to follow my mouse cursor. ( I am easily able to do this).  Where things get hard is that I want the rectangle to rotate around it's bottom right corner, to do this I've found that I need to use a matrix transformation.  At this point I am able to have my rectangle rotate around the bottom right point, but I cannot figure out how to have it follow my mouse cursor as well while rotating.  The reason being that with a matrix you can only tell it a amount of radians to rotate (matrix.rotate) rather than just being able to set its current rotation.... Here is my code
    var point:Point=new Point(myRectangle.x+myRectangle.width/2, myRectangle.y+myRectangle.height/2);
    function rotateObject( event:Event ):void
              var m:Matrix=myRectangle.transform.matrix;
                                  m.tx -= point.x;
                                  m.ty -= point.y;
                                  m.rotate (45*(Math.PI/180));
                                  m.tx += point.x;
                                  m.ty += point.y;
                                  myRectangle.transform.matrix=m;
    addEventListener( Event.ENTER_FRAME, rotateObject);
    So with the current code it is constantly rotating around the bottom right corner, I have tried changing the "45" to "Math.atan(mouseX/mouseY), but again it seems that would only work if i could set the rotation of the matrix to that rather than telling it how much to rotate by....
    Any thoughts or ideas would be much appreciated, thanks!

    can you not calculate the new rotation based on the mouse position and the rotate by the difference with the current rotation on your rectangle?
    function rotateObject( event:Event ):void
              var newRot:Number = Math.atan(mouseX/mouseY);
              var rotationDelta:Number = myRectangle.rotation - newRotation
              var m:Matrix=myRectangle.transform.matrix;
                                  m.tx -= point.x;
                                  m.ty -= point.y;
                                  m.rotate (rotationDelta*(Math.PI/180));
                                  m.tx += point.x;
                                  m.ty += point.y;
                                  myRectangle.transform.matrix=m;

  • Drag'n drop : reacting/animating on drag, according to mouse pos in target

    Hi fellow Java coders,
    I'm using drag'n drop support for some JPanel I'm using in order to make them able to change their layout in their parent or to stack themselves in a tab panel.
    The drag n drop itself works fine (I took the example provided in do, the one with drag'n'dropped children pics).
    But I would like to be able to react according to mouse position in the target panel, the one that receives the drop. I would like to change mouse cursor according to where is the mouse position inside the target panel, or animating / repainting things inside this target panel.
    The lock I have is that with drag'n drop, MouseListener is not called at all when in drag movement, so I can't handle mouse events.
    Is there a way to handle this case, when you wan't to react when dragging data above a possible target component, before having dropped it ?
    Thank you in advance,
    Alexis.

    This grew larger than I planned, but here is an example that show different cursors for different components.
    Drag from the center and the cursor will change for each of the border labels.
    The code I origionally used this in uses custom cursors Crated by System.createCustomCursor.
    This is not really pretty, but it works.
    import java.awt.*;
    import java.awt.dnd.*;
    import javax.swing.*;
    import java.awt.dnd.peer.*;
    import java.awt.datatransfer.*;
    public class DnDFeedBack extends JFrame
        public DnDFeedBack()
            super( "DnD Feed Back Example");
            setDefaultCloseOperation( EXIT_ON_CLOSE );
            JPanel panel = new JPanel( new BorderLayout() );
            JLabel comp = new JLabel( "North Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
            panel.add( comp, BorderLayout.NORTH );
            comp = new JLabel( "East Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR ));
            panel.add( comp, BorderLayout.EAST );
            comp = new JLabel( "West Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.TEXT_CURSOR ));
            panel.add( comp, BorderLayout.WEST );
            comp = new JLabel( "South Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ));
            panel.add( comp, BorderLayout.SOUTH );
            comp = new JLabel( "Drag Source" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new FeedBackDS( comp );
            panel.add( comp, BorderLayout.CENTER );
            setContentPane( panel );
            pack();
            setLocationRelativeTo( null );
            setVisible( true );
        public static void main( String[] args )
            new DnDFeedBack();
        public class FeedBackDS extends DragSourceAdapter implements DragGestureListener
            public FeedBackDS( JComponent comp )
                new MYDragSource().createDefaultDragGestureRecognizer(
                                                                     comp, // component where drag originates
                                                                     DnDConstants.ACTION_COPY_OR_MOVE, // actions
                                                                     this); // drag gesture listener
            public void dragGestureRecognized(DragGestureEvent dge)
                dge.startDrag( DragSource.DefaultMoveNoDrop,
                               new java.awt.datatransfer.StringSelection( "FAKE DATA") );
        public class DTFeedBackListener extends DropTargetAdapter
            JComponent comp;
            Cursor cursor;
            public DTFeedBackListener( JComponent comp, Cursor cursor )
                DropTarget dt = new DropTarget( comp, this );
                dt.setDefaultActions(DnDConstants.ACTION_COPY_OR_MOVE);
                this.comp = comp;
                this.cursor = cursor;
            public void dragExit(DropTargetEvent dte)
                setFeedBackCursor(DragSource.DefaultMoveNoDrop);
            public void dragEnter(DropTargetDragEvent dtde)
                dtde.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE );
                setFeedBackCursor(cursor);
            public void drop(DropTargetDropEvent dtde){}
        public class MYDragSource extends DragSource
            public MYDragSource()
                super();
            protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
                return new MYDragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
        private static Cursor fbCursor;
        public class MYDragSourceContext extends DragSourceContext
            private transient DragSourceContextPeer peer;
            private Cursor              cursor;
            public MYDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
                super( dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
                peer         = dscp;
                cursor       = dragCursor;
            protected synchronized void updateCurrentCursor(int dropOp, int targetAct, int status)
                setCursorImpl(fbCursor);
            private void setCursorImpl(Cursor c)
                if( cursor == null || !cursor.equals(c) )
                    cursor = c;
                    if( peer != null ) peer.setCursor(cursor);
        public static void setFeedBackCursor( Cursor cursor )
            fbCursor = cursor;
    }

  • Zooming image from mouse position(like in  windows vista photo gallery)

    hello all;
    here's my situation, hope someone can help..
    i wanna Zoom an image, which zoom from my mouse position
    like in windows photo gallery in windows vista
    so i do this..
    g2.translate(iMoux,iMouy);       
            g2.scale(zoom, zoom);       
            g2.translate(-iMoux,-iMouy);       
            g.drawImage(icon.getImage(), iSposx, iSposx, d.width/2-iValue, d.height-iBawah, null);
            g.drawImage(icon2.getImage(), d.width/2, iSposy, d.width/2-iValue, d.height-iBawah, null);the problem come when i move my mouse to the different location (like from top right to bottom left)
    the zoom image displayed in the screen like jump from latest location to new location
    anybody can help me...a clue how to do that?
    thx appreciate your help guys
    mao
    Edited by: KingMao on 31 Mei 08 14:27

    Hi Frank.
    Thanks for the response.
    Agreed, the pertinent question is why can't my colleague edit the JPG exported by Aperture. It's probably also worth pointing out, the same problem occurs with JPGs exported from iPhoto.
    The Windows software usually plays nicely with JPGs by all acounts, just not the ones I send - which I do via eMail or my public space on Mobile Me incidently.
    So, another key question is: all settings being equal (color profile, quality, etc.) are the JPGs as produced by iPhoto and Aperture indistinguishable from those produced by other apps on other platforms - i.e. does the use of JPG enforce a common standard?
    If that is the case, I suspect ours might be a permissions issue.
    According to the Microsoft support page on editing in Windows Live Photo Gallery, the inability to edit a picture is commonly caused by unsupported file type, or read-only attribute set on the file.
    Unfortunately, he and I are not in the same place, and he's not particularly au-fait with this type of problem solving. Hence, before involving him, I'd like to know:
    1. it's possible (i.e. someone else does it), and,
    2. what's involved (at my end and/or his).
    Thanks again,
    PB

  • Mouse position inside a movieclip area

    hey
    i am trying to solve this problem:
    how can i test the position of the mouse inside the area of a specific movieclip WITHOUT using rollover and rollout events?
    the movieclip is the irregular shape (star)
    i need to do some action according to the position of mouse (inside/outside of the movieclip area) but i can not use rollover event because i have a button placed over the movieclip.
    thanks for help

    it'll probably be easier for you to change your setup so you can use a rollover/rollout.  otherwise, you have to use a shape-based hittest (check gskinner) or the geometry of your shape.

  • Easing a gotoAndStop(frame) given by the mouse position

    Hi there.
    I have an external swf loaded into the background and i want it to go to a frame according to the mouse vertical position.
    Example: when the mouse is on the bottom part of the screen the movie is in the frame 0 and when it is on the top value goes to 800.
    so far i did it like this:
    _root.onEnterFrame = function ()&#8232;{
         var frame:Number = Stage.height-_ymouse;
         bgContainer.gotoAndStop(frame);
         &#8232;}
    But somehow i need it to ease between the values given by the mouse position so that when there is a fast movement of the mouse, the swf only gradually goes to the frame equivalent to the last mouse position.
    any sugestions??
    Cheers!

    actualFrame ist not a number NaN so i can't use it to define a frame to the clip to stop..
    I just need a function that makes something like this:
    _ymouse           ---->            clip.gotoAndStop()
         1                  ---->                     1
         800              ---->                     16
         800              ---->                     26
         800              ---->                     67
         800              ---->                     135
         800              ---->                     233
         800              ---->                     358
         800              ---->                     498
         800              ---->                     571
         800              ---->                     704
         800              ---->                     731
         800              ---->                     800

  • System not sensing mouse position

    Starting today, my computer (iMac G5 PPC) no longer senses the position of my mouse pointer. For instance:
    - The dock doesn't magnify when the mouse is in it
    - None of the corners activate things like screensaver, expose, desktop
    - When I select a menu in the menu bar, moving the mouse over another menu item doesn't open that menu.
    In other words, OSX simply has no clue where my mouse pointer is located as I move it for all those neat automatic things. Yet, I can still use the mouse to click on items to make them work, then OSX knows where the mouse is.
    I've rebooted several times to no effect, but did notice something. As apps start up, the instant a window opens, OSX will sense the mouse position for that brief moment. For example, putting the mouse over the dock doesn't magnify, but when an app window appears, the dock will magnify that very instance. Moving the mouse out of the dock area doesn't unmagnify the dock, it's stuck in that state until either another window opens, causing OSX to sense the new position, or I click any mouse button which all gets OSX's attention and senses the mouse position.
    The pointer never changes when I'm over things like Links.
    Strange stuff. The mouse moves fine, it's just not being detected as it moves.
    Now, yesterday I installed a new ScanSnap scanner with the ScanSnap Manager software and Acrobat Standard ver. 7. But the mouse didn't have this behavior yesterday, or even this morning. This strange problem just appeared out of the blue mid-day today.
    I've since used Disk Utility and Onyx, and re-installed the 10.4.9 update. I switched to another user account, no difference, so it's definitely system wide.
    This doesn't stop me from using my iMac, but I just don't know how to fix this mouse issue besides a OSX re-install.

    Ok everybody, I finally got proper behavior, it's just too bad I'm not sure of the procedure.
    When I go to bed I usually run the mouse pointer to the upper left corner to activate the screensaver. Of course it didn't work. But I also knew that clicking a button causes the mouse to be sensed, so I was pushing some of the buttons while in the corner to see if I could get the screensaver going.
    Well, after doing this, everything is back to normal operation again. So, I fixed it totally by accident. Makes me wonder if there's some features that are turned on and off somehow by doing whatever it was I did up in that corner.
    Just so you know, I use a Logitech Cordless Optical Trackman. I swapped to the original Apple corded mouse but that made no difference.
    I never had a chance to try the suggestions since I just read them before posting this.
    Anyway, I hope I don't do again whatever it was that caused the behavior, but I am going to store this info in DEVONthink just in case something like this happens again.
    Anyway, it would still be interesting if someone could shed some light on this fix I accidently found. Perhaps some hidden capabilities/features? Or just dumb luck?

  • I created a PDF of my book in Preview and encrypted it. When opened in Adobe Reader, it is rotated to the vertical position rather than the original landscape position. How do I fix this in Preview? I don't want my buyers to have to hassle with rotating.

    I created a PDF of my book in Preview and encrypted it. When opened in Adobe Reader, it is rotated to the vertical position rather than the original landscape position. How do I fix this in Preview? I don’t want to hassle my buyers with rotating. There was no option in Preview to account for this automatic and unwanted rotation.

    Then you rotate it and SAVE or SAVE AS and it will remain that way.

  • MAC OS X + stage.fullScreenSourceRect + renderMode set to GPU = problem with mouse position

    When setting stage.fullScreenSourceRect, stage.displayState to StageDisplayState.FULL_SCREEN_INTERACTIVE; and renderMode to GPU, mouse position is read incorrectly. This is not only for mouseX and mouseY position, but also all the mouse interactions with Sprites, Buttons etc are not working correctly.
    Anybody know a solution for this issue?
    Here is the bug reported, but there is no response yet.
    https://bugbase.adobe.com/index.cfm?event=bug&id=3486120
    Greg.

    Bump up.
    Anybody has the same problem and have an idea how to fix it? Or please just check if you have the same problem.. I'm going to submit my game "Amelia and Terror of the Night" (successfully added to iOS store) to MAC App Store but can't do it while this problem appears.
    I am disappointed nobody  even verified the bugs I submitted at  the bugbase.adobe.com for AIR 3.5 and 3.6
    thanks
    Greg

  • Hwo to "track the mouse position"

    I m a java newbie, and need to write a small program to track the mouse position.
    basically, it opens a small window, and tell you the current mouse x, y coordinate. when mouse moves, hte x, y changes...
    by the way, how can i compile it to .exe file, after i finished coding.
    i try this way, but so many errors.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class mouseWin {
    public static void main(String[] args)
              protected int last_x=0, last_y=0;
              mouseMoved(MouseEvent e);
    JFrame frame = new JFrame("Mike's Mouse");
    JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
    frame.getContentPane().add(X);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
         public mouseMoved(mouseEvent e)
              last_x = e.getx();
              last_y = e.gety();

    please help.
    i rewrite the code, but still cannot get it work
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.EventListener;
    public class mouseWin implements MouseMotionListener
    public static void main(String[] args)
                   int last_x;
                   int last_y;
                   last_x = 0;
                   last_y = 0;
                   JFrame frame = new JFrame("Mike's Mouse");
                   JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
              frame.getContentPane().add(X);
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.pack();
                   frame.setVisible(true);
         public void mouseMoved(MouseEvent e)
              last_x = e.getx();
              last_y = e.gety();
              JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
    }

  • Mouse position on screen

    is there any way to get the mouses position on the screen (not a window)?
    Stephen

    Component c = (Component)e.getSource();
    Point p = e.getPoint();
    SwingUtilities.convertPointToScreen(p, c);
    System.out.println(p);

  • Mouse position capturing

    I was wondering if there is a way to capture the mouse position w/o the use of a frame or jframe? I already know how to use the MouseListener on the JFrame/Frame, but that is no help to me since I'm not using a frame at all. Any suggestions????

    What is your goal. This will work -- (the window is 1 pixel!) -- because the robot starts a "drag" and
    swing has mouse capture during drag, but as soon as the use clicks, it's over...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) throws AWTException {
            JWindow w = new JWindow();
            Container cp = w.getContentPane();
            cp.addMouseMotionListener(new MouseMotionListener() {
                public void mouseDragged(MouseEvent e) {
                       System.out.println(e.getPoint());
                public void mouseMoved(MouseEvent e) {
            w.setBounds(new Rectangle(0,0,1,1));
            w.setVisible(true);
            Robot rob = new Robot();
            rob.mouseMove(0,0);
            rob.mousePress(InputEvent.BUTTON1_MASK);
            rob.mouseMove(100,100);
    [/code[

  • Detect Mouse Position?

    I can't (within actionscript 3) determine where the mouse is
    relative to the flash player window.
    I can get stage.mouseX and stage.mouseY but those coordinates
    are in relation to the size of the entire ORIGINAL stage at compile
    time.
    I need to know where the mouse is in relation to the window
    playing the swf, which is significantly smaller than the original.
    That is the play screen has been resized.
    If I zoom way in and scroll to the right edge of the stage
    and mouseover a spot on the right edge, then trace the mouse
    position (in a mouseover event proc) it shows me a number that is
    the width of the ORIGINAL stage. It seems to be completely
    oblivious to the play window.
    Is there any way at all to determine where the mouse is
    relative to the play window?
    For example,
    if the original stage is 1350 and the play window is 540 and
    I'm zoomed WAY in and scrolled all the way to the right and
    I put the mouse directly in the middle of the window,
    I need something that tells me (in actionscript 3) that the
    mouse's x coordinate is at 270, NOT 12XX (somewhere near the end of
    the orginal size of the stage).
    Is this possible in Flash C3??

    Hi there!
    I don´t know if it´s right but have you tried
    localX
    localY
    from the occuring MouseEvent?
    Hope that helps :)
    CU
    Ingo

  • Convert mouse position to image position

    Using a zoomed IMAQ image in an image control, I want to recover the position of the mouse in the co-ords of the underlying image. LastMousePositionX (and Y) give the info I want but they are one click in the past and not the current position. Amazingly, there doesn't appear to be an equivalent CurrentMousePositionX. I can't seem to find the info I need to do the conversion manually. The mousedown event returns the current mouse position and I can get the position in the image container by subtracting off its left and top position. But to convert this to the image position I need to know both the zoom and where the images origin is relative to what is displayed. I can't seem to find that origin position in the list of property nodes. The only thing I can seem to come up with is to extract the info from teh image information string, but this seems like an incredibly poor way to extract such obvious information - espeically since the info must be calculated to put in the string anyway. Can anyone help with this?

    Hi,
    I am confused why you get the mouse position one click in the past because it seems to work ok for me. I've had to use four of the image properties to recreate the effect using the mousemove event, but this seems to give the same values as the Last Mouse Position property so I think it does what you want. I couldn't see an origin property so I did the conversion using the position given at the image center. I wanted to post a snippet here but I'm new to posting and couldn't seem to get it to work for the whole block diagram, so I'm using a screenshot instead. I hope this helps in some way.
    Will
    Attachments:
    mouse position test.vi ‏58 KB

Maybe you are looking for

  • Ftp to a local ftp server doesn't work for VIREX 7.7

    Has anyone else experienced this and know of a work-around? I have mac 10.3.9 machines not connected to the internet and running Virex 7.7. I have them setup to access signature files I download to a local ftp server on our subnet. This works fine. W

  • Check if VI is a control (.ctl)

    Given an array of VI references, is there a method to determine which VIs are actually controls (.ctl files)?  (Other than getting the path and checking that the file extension is .ctl.  I was hoping for a more direct way.  ) Thanks, Joel Solved! Go

  • Best way to handle scrolling on iphone?

    What's the best way to handle scrolling? The ios has a specific style of scrolling, click and drag, with a sort of elastic effect at the limits. What's the best way to appraoch this? Create a script that mimics this same behavior? In a related questi

  • Outlook 2010 - Losing image in signature after reboot

    Hi, I have a user that uses Outlook 2010, they have a standard signature and after a reboot they have lost an image within it. Its a Written signature in the signature to make things worse. The rest of the content remains, just the one image is missi

  • Oracle instance shutdown normal vs immediate (users connected) how-to?

    Hello Oracle crowd, recently, i tried to shutdown my instance Oracle 9.2.0.1.0 using sqlplus shutdown. i assume the default is shutdown normal but the instance would not shutdown. after reading the admin docs i realized it must be waiting for connect