Forum

Skia Non-Affine transforms not displaying properly

Hi,

I’ve been trying to get this demo working in VL.Skia for a bit.

This would allow to display a layer (an image for instance) in any transformation defined by 4 corner points.

First 2 attempts were porting the ComputeMatrix method to VL, eventually I figured out that SKMatrix Persp1 values never have any effect in matrix multiplication when SKMatrix is converted to Matrix due to the way the Matrix is ordered. I’ve made a custom ToMatrix/reordering operations that allows the multiplication to happen closer to how it should but still it didn’t really work in most cases.

So I decided to just f* it and compile the original code to a class library and load that in VL which in theory should just work (should’ve just started like this). Except it doesn’t. Feeding the method the very same input data (breakpoint in VS, points copied over to VS) I do get the same SKMatrix (makes sense) but visually the transformation is still entirely off.

In the example there doesn’t seem to be anything fancy happening - this is the whole code dealing with transforming the output (matrix is a field containing the result of the ComputeMatrix() method):

// Display the bitmap using the matrix
        canvas.Save();
        canvas.SetMatrix(matrix);
        canvas.DrawBitmap(bitmap, 0, 0);
        canvas.Restore();

So I’m concluding the issue is somewhere deeper…

v 2019.2.0-0125

SkiaNonAffineTransforms.zip (233.9 KB)

Also tested the Xamarin example with both SW rendered SKCanvasView and GPU accelerated SKGLView. The behaviors are different in extreme cases (concave shapes) but generally both work.

Hey domj!

I found the bugger. ToMatrix [SKMatrix] was messing up the last column of the matrix.

fixed in upcoming

2 Likes