Forum Libraries, Components, and Plugins

SKMatrix set max scale

Hi. I am trying to control pinch/pan gestures on the TouchManipulationBitmap which also has drawing functionality.

How could I control the max scale value of the image?

Minumum scale I've set to the initial calculated scale by doing next steps, in the OnTouchEffectAction(object sender, TouchActionEventArgs args) method:

case TouchActionType.Released:
     // initialBitmapScaleX is always calculated correctly when adding bitmap to the page   
    bool isSmallScaling = bitmap.Matrix.ScaleX < initialBitmapScaleX || bitmap.Matrix.ScaleY < initialBitmapScaleY;

 if (isSmallScaling)
    bitmap.Matrix = SKMatrix.MakeScale(initialBitmapScaleX, initialBitmapScaleY);

But how could I control max scale of the image? I've tried doing this:

if (bitmap.Matrix.ScaleX > maxBitmapScaleX || bitmap.Matrix.ScaleY > maxBitmapScaleY)
  bitmap.Matrix = SKMatrix.MakeScale(maxBitmapScaleX, maxBitmapScaleY);

Bitmap scale value would be set to max available, but it will have TransX and TransY set to 0 - so it would be placed in the top left corner.

If image is scaled more than available, then make its scale value as max but save it's position on the screen - this is my goal.

Any help would be appreciated.

Thanks in advance!

Sign In or Register to comment.