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 SKImage FromEncodedData(Stream data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } using (var stream = SKBitmap.WrapManagedStream(data)) 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(byte[] buffer, SKImageInfo bitmapInfo) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } unsafe { 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)); } unsafe { 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 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); } }