You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Is non affine transformation impossible in Win2D? I found this MAUI issue with the same question without response.
I'm not a mathematician, so I've been currently struggling rewriting my SkiaSharp transformation (which I also found on the internet):
publicstaticSKMatrixComputeMatrix(SKSizesize,SKPointupperLeft,SKPointupperRight,SKPointlowerLeft,SKPointlowerRight){// Scale transformvarS=SKMatrix.CreateScale(1/size.Width,1/size.Height);// Affine transformvarA=newSKMatrix{ScaleX=upperRight.X-upperLeft.X,SkewY=upperRight.Y-upperLeft.Y,SkewX=lowerLeft.X-upperLeft.X,ScaleY=lowerLeft.Y-upperLeft.Y,TransX=upperLeft.X,TransY=upperLeft.Y,Persp2=1};// Non-Affine transformA.TryInvert(outvarinverseA);varabPoint=inverseA.MapPoint(lowerRight);vara=abPoint.X;varb=abPoint.Y;varscaleX=a/(a+b-1);varscaleY=b/(a+b-1);varN=newSKMatrix{ScaleX=scaleX,ScaleY=scaleY,Persp0=scaleX-1,Persp1=scaleY-1,Persp2=1};// Multiply S * N * Avarresult=SKMatrix.CreateIdentity();result=result.PostConcat(S);result=result.PostConcat(N);result=result.PostConcat(A);returnresult;}
to System.Numerics implementation, but I realized Matrix3x2 lacks the perspective elements so I have no way to complete it.
My use case is I'm making a projector calibration where you set corner points and the whole canvas would fit into those points. I wanted to compute the matrix and set it to the drawing session like drawingSession.Transform = matrix similarly to how I did it in SkiaSharp before. But since Matrix3x2 is too small... unless there is some math magic I don't know about, this is currently impossible?
If so, please take this as a feature request.
The text was updated successfully, but these errors were encountered:
You are correct that perspective transforms are not possible with a Matrix3x2. There are tricks you could use, where you increase the X and Y scale of an image based on some "Z" value, or using a custom effect, but it isn't inherently built into Win2D.
The Composition layer allows for this, using Visual.TransformMatrix (which is 4x4), and has some interop with Win2D, but Win2D itself is scoped to 2D rendering.
Hi! Is non affine transformation impossible in Win2D? I found this MAUI issue with the same question without response.
I'm not a mathematician, so I've been currently struggling rewriting my SkiaSharp transformation (which I also found on the internet):
to
System.Numerics
implementation, but I realized Matrix3x2 lacks the perspective elements so I have no way to complete it.My use case is I'm making a projector calibration where you set corner points and the whole canvas would fit into those points. I wanted to compute the matrix and set it to the drawing session like
drawingSession.Transform = matrix
similarly to how I did it in SkiaSharp before. But since Matrix3x2 is too small... unless there is some math magic I don't know about, this is currently impossible?If so, please take this as a feature request.
The text was updated successfully, but these errors were encountered: