public static SKBitmap Decode(SKStream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using (var codec = SKCodec.Create(stream)) { if (codec == null) { return(null); } return(Decode(codec)); } }
public static SKBitmap Decode(SKData data, SKImageInfo bitmapInfo) { if (data == null) { throw new ArgumentNullException(nameof(data)); } using (var codec = SKCodec.Create(data)) { if (codec == null) { return(null); } return(Decode(codec, bitmapInfo)); } }
public static SKBitmap Decode(string filename, SKImageInfo bitmapInfo) { if (filename == null) { throw new ArgumentNullException(nameof(filename)); } using (var codec = SKCodec.Create(filename)) { if (codec == null) { return(null); } return(Decode(codec, bitmapInfo)); } }
public static SKBitmap Decode(byte[] buffer, SKImageInfo bitmapInfo) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } fixed(byte *b = buffer) { using (var skdata = SKData.Create((IntPtr)b, buffer.Length)) using (var codec = SKCodec.Create(skdata)) { return(Decode(codec, bitmapInfo)); } } }
public static SKImageInfo DecodeBounds(byte[] buffer) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } fixed(byte *b = buffer) { using (var skdata = SKData.Create((IntPtr)b, buffer.Length)) using (var codec = SKCodec.Create(skdata)) { return(codec?.Info ?? SKImageInfo.Empty); } } }
public static SKImage FromEncodedData(SKStream data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } using (var codec = SKCodec.Create(data)) using (var bitmap = SKBitmap.Decode(codec, codec.Info)) { if (bitmap == null) { return(null); } return(FromBitmap(bitmap)); } }
public static SKBitmap Decode(SKCodec codec) { if (codec == null) { throw new ArgumentNullException(nameof(codec)); } var info = codec.Info; if (info.AlphaType == SKAlphaType.Unpremul) { info.AlphaType = SKAlphaType.Premul; } // for backwards compatibility, remove the colorspace info.ColorSpace = null; return(Decode(codec, info)); }
public static SKImage FromEncodedData(string filename) { if (filename == null) { throw new ArgumentNullException(nameof(filename)); } using (var stream = SKBitmap.OpenStream(filename)) using (var codec = SKCodec.Create(stream)) using (var bitmap = SKBitmap.Decode(codec, codec.Info)) { if (bitmap == null) { return(null); } return(FromBitmap(bitmap)); } }
public static SKBitmap Decode(SKCodec codec, SKImageInfo bitmapInfo) { if (codec == null) { throw new ArgumentNullException(nameof(codec)); } var bitmap = new SKBitmap(bitmapInfo); var result = codec.GetPixels(bitmapInfo, bitmap.GetPixels(out var length)); if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput) { bitmap.Dispose(); bitmap = null; } return(bitmap); }
public static SKBitmap Decode (SKCodec codec) { if (codec == null) { throw new ArgumentNullException (nameof (codec)); } return Decode (codec, codec.Info); }
public static SKBitmap Decode (SKCodec codec, SKImageInfo bitmapInfo) { if (codec == null) { throw new ArgumentNullException (nameof (codec)); } // construct a color table for the decode if necessary SKColorTable colorTable = null; int colorCount = 0; if (bitmapInfo.ColorType == SKColorType.Index8) { colorTable = new SKColorTable (); } // read the pixels and color table var bitmap = new SKBitmap (bitmapInfo, colorTable); IntPtr length; var result = codec.GetPixels (bitmapInfo, bitmap.GetPixels (out length), colorTable, ref colorCount); if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput) { bitmap.Dispose (); bitmap = null; } return bitmap; }
public static SKBitmap Decode(SKData data) { using (var codec = SKCodec.Create(data)) { return(Decode(codec)); } }
public static SKBitmap Decode(SKStream stream) { using (var codec = SKCodec.Create(stream)) { return(Decode(codec)); } }
public static SKImageInfo DecodeBounds(SKData data) { using (var codec = SKCodec.Create(data)) { return(codec.Info); } }
public static SKImageInfo DecodeBounds(SKStream stream) { using (var codec = SKCodec.Create(stream)) { return(codec.Info); } }