Inheritance: SKObject
Example #1
0
        public static SKImage FromEncodedData(SKStream data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            using (var codec = SKCodec.Create(data)) {
                if (codec == null)
                {
                    return(null);
                }

                var bitmap = SKBitmap.Decode(codec, codec.Info);
                if (bitmap == null)
                {
                    return(null);
                }

                bitmap.SetImmutable();
                return(FromPixels(bitmap.PeekPixels(), delegate {
                    bitmap.Dispose();
                    bitmap = null;
                }));
            }
        }
Example #2
0
 public static SKImageInfo DecodeBounds(Stream stream)
 {
     if (stream == null)
     {
         throw new ArgumentNullException(nameof(stream));
     }
     return(DecodeBounds(SKStream.WrapManagedStream(stream)));
 }
Example #3
0
 public static SKBitmap Decode(Stream stream, SKImageInfo bitmapInfo)
 {
     if (stream == null)
     {
         throw new ArgumentNullException(nameof(stream));
     }
     return(Decode(SKStream.WrapManagedStream(stream), bitmapInfo));
 }
Example #4
0
        public bool WriteStream(SKStream input, int length)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            return(SkiaApi.sk_wstream_write_stream(Handle, input.Handle, (IntPtr)length));
        }
Example #5
0
		public static SKImageInfo DecodeBounds (SKStream stream)
		{
			if (stream == null) {
				throw new ArgumentNullException (nameof (stream));
			}
			using (var codec = SKCodec.Create (stream)) {
				return codec?.Info ?? SKImageInfo.Empty;
			}
		}
Example #6
0
        public static SKData Create(SKStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return(Create(stream, stream.Length));
        }
Example #7
0
        public static SKData Create(SKStream stream, long length)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return(GetObject(SkiaApi.sk_data_new_from_stream(stream.Handle, (IntPtr)length)));
        }
Example #8
0
        public static SKData Create(Stream stream, long length)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return(Create(SKStream.WrapManagedStream(stream), length));
        }
Example #9
0
 public static SKBitmap Decode(SKStream stream, SKImageInfo bitmapInfo)
 {
     if (stream == null)
     {
         throw new ArgumentNullException(nameof(stream));
     }
     using (var codec = SKCodec.Create(stream)) {
         return(Decode(codec, bitmapInfo));
     }
 }
Example #10
0
        protected override void DisposeManaged()
        {
            if (disposeStream && stream != null)
            {
                stream.Dispose();
                stream = null;
            }

            base.DisposeManaged();
        }
Example #11
0
 public static SKImage FromPixelCopy(SKImageInfo info, SKStream pixels, int rowBytes)
 {
     if (pixels == null)
     {
         throw new ArgumentNullException(nameof(pixels));
     }
     using (var data = SKData.Create(pixels)) {
         return(FromPixelData(info, data, rowBytes));
     }
 }
Example #12
0
        public static SKCodec Create(SKStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            var codec = GetObject <SKCodec> (SkiaApi.sk_codec_new_from_stream(stream.Handle));

            stream.RevokeOwnership(codec);
            return(codec);
        }
Example #13
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);
			}
		}
Example #14
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (disposeStream && stream != null)
                {
                    stream.Dispose();
                    stream = null;
                }
            }

            base.Dispose(disposing);
        }
Example #15
0
        public static SKCodec Create(SKStream stream, out SKCodecResult result)
        {
            if (stream == null)
                throw new ArgumentNullException(nameof(stream));

            fixed(SKCodecResult *r = &result)
            {
                var codec = GetObject(SkiaApi.sk_codec_new_from_stream(stream.Handle, r));

                stream.RevokeOwnership(codec);
                return(codec);
            }
        }
Example #16
0
        public SKFrontBufferedManagedStream(SKStream nativeStream, int bufferSize, bool disposeUnderlyingStream)
        {
            var length   = nativeStream.HasLength ? nativeStream.Length : 0;
            var position = nativeStream.HasPosition ? nativeStream.Position : 0;

            disposeStream = disposeUnderlyingStream;
            stream        = nativeStream;
            hasLength     = nativeStream.HasPosition && nativeStream.HasLength;
            streamLength  = length - position;
            offset        = 0;
            bufferedSoFar = 0;
            bufferLength  = bufferSize;
            frontBuffer   = new byte[bufferSize];
        }
Example #17
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));
         }
 }
Example #18
0
        public static SKImage FromEncodedData(SKStream data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            using (var skdata = SKData.Create(data)) {
                if (skdata == null)
                {
                    return(null);
                }
                return(FromEncodedData(skdata));
            }
        }
Example #19
0
        public static SKCodec Create(SKStream stream, out SKCodecResult result)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (stream is SKFileStream filestream && !filestream.IsValid)
                throw new ArgumentException("File stream was not valid.", nameof(stream));

            fixed(SKCodecResult *r = &result)
            {
                var codec = GetObject(SkiaApi.sk_codec_new_from_stream(stream.Handle, r));

                stream.RevokeOwnership(codec);
                return(codec);
            }
        }
Example #20
0
 public static SKPicture Deserialize(SKStream stream)
 {
     if (stream == null)
         throw new ArgumentNullException(nameof(stream)); }
Example #21
0
		public static SKCodec Create (SKStream stream)
		{
			if (stream == null)
				throw new ArgumentNullException (nameof (stream));
			var codec = GetObject<SKCodec> (SkiaApi.sk_codec_new_from_stream (stream.Handle));
			stream.RevokeOwnership (codec);
			return codec;
		}
Example #22
0
		public bool WriteStream (SKStream input, int length)
		{
			if (input == null) {
				throw new ArgumentNullException (nameof(input));
			}

			return SkiaApi.sk_wstream_write_stream (Handle, input.Handle, (IntPtr)length);
		}
Example #23
0
        // create a new image from a copy of pixel data

        public static SKImage FromPixelCopy(SKImageInfo info, SKStream pixels) =>
        FromPixelCopy(info, pixels, info.RowBytes);
Example #24
0
 public SKFrontBufferedManagedStream(SKStream nativeStream, int bufferSize)
     : this(nativeStream, bufferSize, false)
 {
 }
Example #25
0
 public static SKImageInfo DecodeBounds(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(codec.Info);
     }
 }
Example #26
0
 public static SKBitmap Decode(SKStream stream)
 {
     using (var codec = SKCodec.Create(stream)) {
         return(Decode(codec));
     }
 }
Example #27
0
        // create a new image from a copy of pixel data

        public static SKImage FromPixelCopy(SKImageInfo info, SKStream pixels)
        {
            return(FromPixelCopy(info, pixels, info.RowBytes));
        }
Example #28
0
		public static SKBitmap Decode (SKStream stream, SKImageInfo bitmapInfo)
		{
			if (stream == null) {
				throw new ArgumentNullException (nameof (stream));
			}
			using (var codec = SKCodec.Create (stream)) {
				return Decode (codec, bitmapInfo);
			}
		}
Example #29
0
		public static SKImageInfo DecodeBounds (SKStream stream)
		{
			if (stream == null) {
				throw new ArgumentNullException (nameof (stream));
			}
			using (var codec = SKCodec.Create (stream)) {
				return codec.Info;
			}
		}
Example #30
0
 public SKImageDecoderResult Decode(SKStream stream, SKBitmap bitmap, SKColorType pref = SKColorType.Unknown, SKImageDecoderMode mode = SKImageDecoderMode.DecodePixels)
 {
     return(SkiaApi.sk_imagedecoder_decode(Handle, stream.Handle, bitmap.Handle, pref, mode));
 }
Example #31
0
 public static SKCodec Create(SKStream stream)
 {
     return(Create(stream, out var result));
 }
Example #32
0
 public static SKCodec Create(SKStream stream) =>
 Create(stream, out var result);