Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2014

    misaligned images after pinch (shrinking)

    i'm working on an app where I place an image on top of another (for a watermark) I have it where the main images is static but the second image I can shrink and rotate. These images are in a canvas. everything seems fine until I manipulate the 2nd image and save it. When I save the image the 2nd image is not lined up where I left it...it is usually higher and to the left of where I placed it. If I don't shrink it or rotate it, it stays in place. so it has to be with the way i'm manipulating it. any ideas?

    touch control code:
    private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
    _initialAngle = ImageTransformation.Rotation;
    _initialScale = ImageTransformation.ScaleX;
    Point firstTouch = e.GetPosition(imgMain, 0);
    Point secondTouch = e.GetPosition(imgMain, 1);
    Point center = new Point(firstTouch.X + (secondTouch.X - firstTouch.X) / 2.0, firstTouch.Y + (secondTouch.Y - firstTouch.Y) / 2.0);
    ImageTransformation.CenterX = center.X;
    ImageTransformation.CenterY = center.Y;
    //used for hidden overlay
    _initialAngleHidden = HiddenImageTransformation.Rotation;
    _initialScaleHidden = HiddenImageTransformation.ScaleX;
    Point firstTouchHidden = e.GetPosition(HiddenimgMain, 0);
    Point secondTouchHidden = e.GetPosition(HiddenimgMain, 1);
    Point centerHidden = new Point(firstTouchHidden.X + (secondTouchHidden.X - firstTouchHidden.X) / 2.0, firstTouchHidden.Y + (secondTouchHidden.Y - firstTouchHidden.Y) / 2.0);
    HiddenImageTransformation.CenterX = centerHidden.X;
    HiddenImageTransformation.CenterY = centerHidden.Y;


    private void OnPinchDelta(object sender, PinchGestureEventArgs e)
    ImageTransformation.Rotation = _initialAngle + e.TotalAngleDelta;
    ImageTransformation.ScaleX = _initialScale * e.DistanceRatio;
    ImageTransformation.ScaleY = ImageTransformation.ScaleX;

    HiddenImageTransformation.Rotation = _initialAngleHidden + e.TotalAngleDelta;
    HiddenImageTransformation.ScaleX = _initialScaleHidden * e.DistanceRatio;
    HiddenImageTransformation.ScaleY = HiddenImageTransformation.ScaleX;

    private void btnSelect_Click(object sender, RoutedEventArgs e)
    photoChooserTask = new PhotoChooserTask();
    photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);

    void photoChooserTask_Completed(object sender, PhotoResult e)
    //Code to display the photo on the page in an image control named myImage.
    BitmapImage pic = new BitmapImage();
    e.ChosenPhoto.Position = 0;

    imgMain.Visibility = Visibility.Visible;
    imgMain.Source = pic;
    HiddenimgMain.Source = pic;

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Oslo, Norway

    Re: misaligned images after pinch (shrinking)

    I am not sure what is saved and restored here, but note that shrinking an image around some fixed point also modifies the position of the image, so make sure that it is saved and restored too. If the shrinking is saved, but the new position is not, it may really appear as a movement towards the top-left corner of the image.

Similar Threads

  1. How to use pinch gesture zoom?
    By ShekChien in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-05-12, 17:23
  2. Как форсировать pinch zoom на Symbian^3 девайсах?
    By vovik-ukr in forum Russian Developer Forum - Форум Российских разработчиков
    Replies: 3
    Last Post: 2010-12-27, 12:15
  3. How to do pinch zoom in Symbian^3 SDK
    By henpe008 in forum Symbian User Interface
    Replies: 6
    Last Post: 2010-09-03, 14:52
  4. Need advice on shrinking jar size
    By deny_winarto in forum Mobile Java General
    Replies: 20
    Last Post: 2009-09-11, 02:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts