Inheritance: SKObject
示例#1
0
 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));
     }
 }
示例#2
0
 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));
     }
 }
示例#3
0
 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));
     }
 }
示例#4
0
        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));
                    }
            }
        }
示例#5
0
        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);
                    }
            }
        }
示例#6
0
 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));
         }
 }
示例#7
0
        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));
        }
示例#8
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));
             }
 }
示例#9
0
        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);
        }
示例#10
0
		public static SKBitmap Decode (SKCodec codec)
		{
			if (codec == null) {
				throw new ArgumentNullException (nameof (codec));
			}
			return Decode (codec, codec.Info);
		}
示例#11
0
		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;
		}
示例#12
0
 public static SKBitmap Decode(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(Decode(codec));
     }
 }
示例#13
0
 public static SKBitmap Decode(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(Decode(codec));
     }
 }
示例#14
0
 public static SKImageInfo DecodeBounds(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(codec.Info);
     }
 }
示例#15
0
 public static SKImageInfo DecodeBounds(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(codec.Info);
     }
 }