Create() public static method

public static Create ( SKData data ) : SKCodec
data SKData
return SKCodec
Example #1
0
 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));
             }
 }
Example #2
0
 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));
             }
 }
Example #3
0
        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));
                        }
                }
            }
        }
Example #4
0
        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);
                        }
                }
            }
        }
Example #5
0
 public static SKBitmap Decode(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(Decode(codec));
     }
 }
Example #6
0
 public static SKBitmap Decode(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(Decode(codec));
     }
 }
Example #7
0
 public static SKImageInfo DecodeBounds(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(codec.Info);
     }
 }
Example #8
0
 public static SKImageInfo DecodeBounds(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(codec.Info);
     }
 }