Reputation: 276
In System.Drawing we will make the bitmap image color as transparent by using maketransparent method Whether SKBITMAP has any other equivalent method for making the color to transparent.
Bitmap imgData = new Bitmap()
imgData.MakeTransparent(Color.White);
//in system.Drawing
Can any one please suggest a solution for making the color as transparent for SkiaSharp.SKBitmap
Upvotes: 4
Views: 2959
Reputation: 148
Setting SKBitmap.Pixels
does the trick.
Here is an extension method:
public static void ClearToTransparent (this SKBitmap bitmap) {
int pixelCount = bitmap.Width * bitmap.Height;
SKColor[] colors = new SKColor[pixelCount];
SKColor transparent = new SKColor(0, 0, 0, 0);
for (int n = 0; n < pixelCount; n++) {
colors[n] = transparent;
}
bitmap.Pixels = colors;
}
Upvotes: 1
Reputation: 5222
I would suggest asking on the official skia forums: https://groups.google.com/forum/#!forum/skia-discuss
I know a quite a bit about skia, but they know everything. SkiaSharp is just a thin wrapper around the native library, so whatever they do just do the same in C#.
Upvotes: 0