-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not work properly ImageFilter and SKMatrix [bug] #627
Comments
Conducted several test. Used code: SKPaint paintFill = new SKPaint()
{
Color = SKColors.White,
Style = SKPaintStyle.Fill,
ImageFilter = SKImageFilter.CreateDropShadow(5, 5, 15, 15, SKColors.Black, SKDropShadowImageFilterShadowMode.DrawShadowAndForeground)
};
SKPaint paintStroke = new SKPaint()
{
Color = SKColors.Black,
Style = SKPaintStyle.Stroke,
StrokeWidth = 1
};
SKPath testPath = new SKPath();
testPath.AddRect(SKRect.Create(0, 0, 100, 100)); test 1SKMatrix matrix = canvas.TotalMatrix;
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeTranslation(200, 200));
canvas.SetMatrix(matrix);
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); It's OK, the rectangle and stroke have moved to the right place. test 2SKMatrix matrix = canvas.TotalMatrix;
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeScale(5, 5));
canvas.SetMatrix(matrix);
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); It's OK, the rectangle and stroke have increased. test 3SKMatrix matrix = canvas.TotalMatrix;
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeScale(2, 2));
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeTranslation(200, 200));
canvas.SetMatrix(matrix);
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); It's OK, the rectangle and stroke have increased in moved. test 4SKMatrix matrix = canvas.TotalMatrix;
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeSkew(2, 2));
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeTranslation(200, 200));
canvas.SetMatrix(matrix);
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); Not everything is ok, the rectangle with the shadow with skew and moved, the stroke only increased and stayed in place, I consider this a bug. test 5SKMatrix matrix = canvas.TotalMatrix;
SKMatrix.PostConcat(ref matrix, SKMatrix.MakeSkew(2, 2));
canvas.SetMatrix(matrix);
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); Not everything is ok, the same behavior as in test 4, only without moving. test 6
Not everything is ok, a rectangle with a shadow in turned, the outline remained in place. Using canvas.DrawRect the same results. |
If removed "ImageFilter = SKImageFilter.CreateDropShadow......" from "paintFill" all tests are normal. |
Thanks for reporting this, I will investigate further. |
@mattleibow Thank you for noticing this issue. Some more simple bug tests. test 7 canvas.SetMatrix(SKMatrix.MakeRotationDegrees(-25f, 50, 50));
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); Not everything is ok, a rectangle with a shadow in turned, the outline remained in place. test 8 canvas.SetMatrix(SKMatrix.MakeSkew(2, 2));
canvas.DrawPath(testPath, paintFill);
canvas.DrawPath(testPath, paintStroke); Not everything is ok, the rectangle with the shadow increased and distorted (stretched out), the stroke has only increased, but not distorted. Such impression that when using "ImageFilter" where that loses the transformation matrix. |
I tried the new version SkiaSharp 1.68.0 in Windows Forms (.NET Framework 4.6.1) All tests from previous messages passed successfully. It's OK. The bug is gone. |
That is great news! The v1.68 update had many fixes. |
Description
When adding to SKPaint filter: ImageFilter SKImageFilter.CreateDropShadow then using the transformation matrix is incomprehensible. It is expected to see that two rectangles turned and shifted to the desired values, but this does not happen. Rotates and moves only one "rectangle"(SKPath ), which is painted paintFill, the other remains untouched and in the same place.
Correct work:
If you remove "ImageFilter = SKImageFilter.CreateDropShadow...." then rotate and move both rectangles.
or
And also if you change the canvas drawing in places. Do this way:
then everything is reflected normally. both rectangles moved.
Tell me, is this a bug or am I doing something wrong?
Code
If you run this code, you can see that one rectangle (white with shadow) turned and moved, another rectangle (with a black stroke) stayed in place at 0,0.
Basic Information
.NET Framework 4.6.1
Windows Forms
SkiaSharp 1.60.3
The text was updated successfully, but these errors were encountered: