4

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

Mohan Selvaraj
  • 236
  • 2
  • 15

2 Answers2

2

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;
}
Magiczne
  • 1,586
  • 2
  • 15
  • 23
Harlan
  • 141
  • 8
-1

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#.

Matthew
  • 4,832
  • 2
  • 29
  • 55
  • Hi @matthew Thank you for your update.I have already the posted the above in the provided forum.Kindly refer the link below. https://groups.google.com/forum/#!topic/skia-discuss/sn8Qxhw5Ckw – Mohan Selvaraj Feb 19 '18 at 19:49