I have a working c# code that create a System.Drawing.Bitmap:
byte[] logoBytes = decodeBase64SafeWeb(json["logo.png"].ToString());
using (Bitmap bitmapold = (Bitmap)Bitmap.FromStream(new MemoryStream(logoBytes)))
{
do my code with bitmapold;
}
I want to replace the usage of System.Drawing library with SkiaSharp, tried following code instead:
` byte[] logoBytes = decodeBase64SafeWeb(json[“logo.png”].ToString());
using (var stream = new SKMemoryStream(logoBytes))
using (var bitmap = SKBitmap.Decode(stream))
{
do my code with bitmap`
Seems that pixels order is different in bitmap and bitmapold.
in “do my code” I iterate over the bitmap and get pixels as follow:
for (int i = 0; i < bmp.Height; i++)
{
// pass through each row
for (int j = 0; j < bmp.Width; j++)
{
Color pixel = bmp.GetPixel(j, i);
For bitmapold (System.Draawing) => all first pixels have real values, while in bitmap (Skiasharp) – all first pixelsare zeros.
I tried to compare the non-zero pixels in bitmap and bitmapold, but failed to do it because bitmaphold pixels are not exposed.
Also I tried get bitmap directly from byte[] and not from stream.
Also added
imageStream.seek(0, SeekOrigin.Begin);
as see here: SKBitmap.Decode(imageStream) is returning null
but got same results.
RiB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.