BaconographyWP8.View.ScalingGifView.ResizeImage C# (CSharp) Method

ResizeImage() public method

Adjust the size of the image according to the coerced scale factor. Optionally center the image, otherwise, try to keep the original midpoint of the pinch in the same spot on the screen regardless of the scale.
public ResizeImage ( bool center ) : void
center bool
return void
        void ResizeImage(bool center)
        {
            if (_coercedScale != 0)
            {
                double newWidth;
                double newHeight;
                if (_interop != null)
                {
                    newWidth = image.Width = Math.Round(_interop.Width * _coercedScale);
                    newHeight = image.Height = Math.Round(_interop.Height * _coercedScale);
                }
                else return;

                viewport.Bounds = new Rect(0, 0, newWidth, newHeight);

                if (center)
                {
                    viewport.SetViewportOrigin(
                        new Point(
                            Math.Round(newWidth / 2),
                            Math.Round(newHeight / 2)
                            ));
                }
                else
                {
                    Point newImgMid = new Point(newWidth * _relativeMidpoint.X, newHeight * _relativeMidpoint.Y);
                    Point origin = new Point(newImgMid.X - _screenMidpoint.X, newImgMid.Y - _screenMidpoint.Y);
                    viewport.SetViewportOrigin(origin);
                }
            }
        }