public static TextureBitmap Load(byte[] bytes, bool createBackgroundTexture = true) { var bitmap = SkiaSharp.SKBitmap.Decode(bytes); if (ColorTransformers.ContainsKey(bitmap.ColorType)) { var result = new TextureBitmap(bitmap.Width, bitmap.Height, createBackgroundTexture); var reader = ColorTransformers[bitmap.ColorType]; int pixelSize = ColorSize[bitmap.ColorType]; var pixels = bitmap.GetPixels(); result.InternalResize(bitmap.Width, bitmap.Height); ColorTransformers[bitmap.ColorType](pixels, result.Bytes, result.Width, result.Height); result.FlipY(); bitmap.Dispose(); result.Apply(); return(result); } else { bitmap.Dispose(); throw new ArgumentException("Image have an unsupported color type: " + bitmap.ColorType); } }