SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.54k
stars
543
forks
source link
[BUG] SKBlendMode.Multiply not working correctly #3017
The multiply blend mode in computer graphics should convert each part of RGBA to float ranging at [0,1], and multiply them. That means if one of the color is 0, then the outcome should be zero no matter what the another one is. However, when I multiply color 0 and color 0xFF000000 (by the way, the uint representation of color takes first byte as alpha, this is inconsistent with the convention). the outcome is not zero.
Code
Draw the following paint
var shader = SKShader.CreateCompose(SKShader.CreateColor(0), SKShader.CreateColor(new(0,0,0,255)), SKBlendMode.Multiply);
var paint = new SKPaint() { Shader = shader };
Expected Behavior
The paint should draw nothing, as the composed color is 0 after multiplication.
Actual Behavior
It draws zero RGB with 255 alpha.
Version of SkiaSharp
3.x (Alpha)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
Windows 11 Home 23H2
Devices
Nitro AN515-58
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Description
The multiply blend mode in computer graphics should convert each part of RGBA to float ranging at [0,1], and multiply them. That means if one of the color is 0, then the outcome should be zero no matter what the another one is. However, when I multiply color 0 and color 0xFF000000 (by the way, the uint representation of color takes first byte as alpha, this is inconsistent with the convention). the outcome is not zero.
Code
Draw the following paint
Expected Behavior
The paint should draw nothing, as the composed color is 0 after multiplication.
Actual Behavior
It draws zero RGB with 255 alpha.
Version of SkiaSharp
3.x (Alpha)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
Windows 11 Home 23H2
Devices
Nitro AN515-58
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct