0

I have an unsolved problem with my InkCanvas in my UWP App.

I saved my strokes in a SQLite Database from a InKCanvas with measurements a*b. Now I want to display this Strokes on another InkCanvas with different measurements than the InkCanvas with a*b (e.g. a/2 * b/2).

How can I change the size of my Strokes? I tried to use:

var allStrokes = myInkCanvas.InkPresenter.StrokeContainer.GetStrokes();
foreach(var item in allStrokes)
{
    item.PointTransform() = ...// I tried to transform my Strokey with a 3x2 Matrix
                               // But it didn't work. 
}

Maybe someone can help.

Julian
  • 33,915
  • 22
  • 119
  • 174
Agredo
  • 131
  • 1
  • 10

1 Answers1

1

The transformation with matrix worked for me.

I have used the Matrix3x2.CreateScale factory method as follows:

var strokes = InkDisplay.InkPresenter.StrokeContainer.GetStrokes();
foreach ( var stroke in strokes )
{
    stroke.PointTransform = 
       Matrix3x2.CreateScale( 
          xScale,
          yScale 
       );
}

Note, that the xScale and yScale values represent relative scale, which means that when you go from ink canvas of size X*Y to ink canvas of size (X/2)*(Y*2), the values would be xScale = 0.5 and yScale = 2.

You can see the sample I have created on my GitHub.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • Thanks you. My roblem was a wrong use of the Matrix. I created it manually und something went wrong. Now all works perfectly with your Code. Especially with the method Matrix3x2.CreateScale(x, y). – Agredo Sep 06 '16 at 21:13
  • Great, happy it helped :-) . Please, mark my answer so that the question is resolved :-) . – Martin Zikmund Sep 07 '16 at 06:04