Inheritance: SKObject
		public static bool IsValid3DColorCube(SKData cubeData, int cubeDimension)
		{
			var minMemorySize = 4 * cubeDimension * cubeDimension * cubeDimension;
			return
				(cubeDimension >= MinColorCubeDimension) && (cubeDimension <= MaxColorCubeDimension) &&
				(null != cubeData) && (cubeData.Size >= minMemorySize);
		}
Exemple #2
0
		public static SKImage FromData (SKData data)
		{
			if (data == null)
				throw new ArgumentNullException (nameof (data));
			var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, IntPtr.Zero);
			return GetObject<SKImage> (handle);
		}
		public static SKColorFilter CreateColorCube(SKData cubeData, int cubeDimension)
		{
			if (cubeData == null)
				throw new ArgumentNullException(nameof(cubeData));
			if (!IsValid3DColorCube(cubeData, cubeDimension))
				throw new ArgumentException("Invalid cube data.", nameof(cubeData));
			return GetObject<SKColorFilter>(SkiaApi.sk_colorfilter_new_color_cube(cubeData.Handle, cubeDimension));
		}
Exemple #4
0
        public static SKImage FromData(SKData data, SKRectI subset)
        {
            if (data == null)
                throw new ArgumentNullException ("data");

            var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, ref subset);
            return GetObject<SKImage> (handle);
        }
Exemple #5
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));
     }
 }
Exemple #6
0
        public static SKImage FromEncodedData(byte[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (data.Length == 0)
            {
                throw new ArgumentException("The data buffer was empty.");
            }

            using (var skdata = SKData.CreateCopy(data)) {
                return(FromEncodedData(skdata));
            }
        }
Exemple #7
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));
                    }
            }
        }
Exemple #8
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);
                    }
            }
        }
Exemple #9
0
        public static SKImage FromEncodedData(string filename)
        {
            if (filename == null)
            {
                throw new ArgumentNullException(nameof(filename));
            }

            using (var skdata = SKData.Create(filename)) {
                if (skdata == null)
                {
                    return(null);
                }
                return(FromEncodedData(skdata));
            }
        }
Exemple #10
0
        public static SKImage FromData(SKData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            var handle = SkiaApi.sk_image_new_from_encoded(data.Handle, IntPtr.Zero);

            if (handle == IntPtr.Zero)
            {
                return(null);
            }
            return(new SKImage(handle));
        }
Exemple #11
0
        public static SKImage FromEncodedData(ReadOnlySpan <byte> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (data.Length == 0)
            {
                throw new ArgumentException("The data buffer was empty.");

                fixed(byte *b = data)
                {
                    using (var skdata = SKData.Create((IntPtr)b, data.Length)) {
                        return(FromEncodedData(skdata));
                    }
                }
        }
Exemple #12
0
 public static SKImage FromData(SKData data)
 {
     return(FromEncodedData(data));
 }
Exemple #13
0
 public static SKImage FromData(SKData data, SKRectI subset)
 {
     return(FromEncodedData(data, subset));
 }
Exemple #14
0
        // Serialize

        public SKData Serialize() =>
        SKData.GetObject(SkiaApi.sk_picture_serialize_to_data(Handle));
Exemple #15
0
 public MyUnmanagedMemoryStream(SKData host) : base((byte *)host.Data, host.Size)
 {
     this.host = host;
 }
Exemple #16
0
 public static SKBitmap Decode(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(Decode(codec));
     }
 }
Exemple #17
0
		public static SKCodec Create (SKData data)
		{
			if (data == null)
				throw new ArgumentNullException (nameof (data));
			return GetObject<SKCodec> (SkiaApi.sk_codec_new_from_data (data.Handle));
		}
Exemple #18
0
		public SKMemoryStream (SKData data)
			: this(SkiaApi.sk_memorystream_new_with_skdata (data), true)
		{
			if (Handle == IntPtr.Zero) {
				throw new InvalidOperationException ("Unable to create a new SKMemoryStream instance.");
			}
		}
Exemple #19
0
		public static SKImageInfo DecodeBounds (SKData data)
		{
			if (data == null) {
				throw new ArgumentNullException (nameof (data));
			}
			using (var codec = SKCodec.Create (data)) {
				return codec.Info;
			}
		}
Exemple #20
0
            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);

                if (disposeHost)
                {
                    host?.Dispose();
                }
                host = null;
            }
Exemple #21
0
        // create (data)

        public static SKCodec Create(SKData data)
        {
            if (data == null)
                throw new ArgumentNullException(nameof(data)); }
Exemple #22
0
 public SKMemoryStream(SKData data)
     : this(SkiaApi.sk_memorystream_new_with_skdata(data))
 {
 }
Exemple #23
0
 public SKData DetachAsData()
 {
     return(SKData.GetObject(SkiaApi.sk_dynamicmemorywstream_detach_as_data(Handle)));
 }
Exemple #24
0
 public extern static sk_stream_memorystream_t sk_memorystream_new_with_skdata(SKData data);
Exemple #25
0
 public static SKTypeface FromData(SKData data, int index = 0)
 {
     return(SKTypeface.FromStream(new SKMemoryStream(data), index));
 }
Exemple #26
0
 public unsafe SKDataStream(SKData host, bool disposeHost = false)
     : base((byte*)host.Data, host.Size)
 {
     this.host = host;
     this.disposeHost = disposeHost;
 }
Exemple #27
0
		public extern static sk_stream_memorystream_t sk_memorystream_new_with_skdata(SKData data);
Exemple #28
0
        internal static SKData FromCString(string str)
        {
            var bytes = Encoding.ASCII.GetBytes(str ?? string.Empty);

            return(SKData.CreateCopy(bytes, (ulong)(bytes.Length + 1)));             // + 1 for the terminating char
        }
Exemple #29
0
 public void DrawAnnotation(SKRect rect, string key, SKData value)
 {
     SkiaApi.sk_canvas_draw_annotation(Handle, ref rect, Util.GetEncodedText(key, SKTextEncoding.Utf8), value == null ? IntPtr.Zero : value.Handle);
 }
Exemple #30
0
		public static SKBitmap Decode (SKData data, SKImageInfo bitmapInfo)
		{
			if (data == null) {
				throw new ArgumentNullException (nameof (data));
			}
			using (var codec = SKCodec.Create (data)) {
				return Decode (codec, bitmapInfo);
			}
		}
Exemple #31
0
 public void DrawNamedDestinationAnnotation(SKPoint point, SKData value)
 {
     SkiaApi.sk_canvas_draw_named_destination_annotation(Handle, ref point, value == null ? IntPtr.Zero : value.Handle);
 }
Exemple #32
0
 public static SKImage FromPixels(SKImageInfo info, SKData data) =>
 FromPixels(info, data, info.RowBytes);
 private SKColorFilter ToColorFilter(SKData uniforms) =>
 ToColorFilter(uniforms, null);
Exemple #34
0
 static SKData()
 {
     empty = new SKDataStatic(SkiaApi.sk_data_new_empty());
 }
Exemple #35
0
 public SKData Encode() =>
 SKData.GetObject(SkiaApi.sk_image_encode(Handle));
Exemple #36
0
 public unsafe SKDataStream(SKData host, bool disposeHost = false)
     : base((byte *)host.Data, host.Size)
 {
     this.host        = host;
     this.disposeHost = disposeHost;
 }
Exemple #37
0
 public SKData Encode(SKEncodedImageFormat format, int quality)
 {
     return(SKData.GetObject(SkiaApi.sk_image_encode_specific(Handle, format, quality)));
 }
Exemple #38
0
 public void DrawUrlAnnotation(SKRect rect, SKData value)
 {
     SkiaApi.sk_canvas_draw_url_annotation(Handle, ref rect, value == null ? IntPtr.Zero : value.Handle);
 }
Exemple #39
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     host = null;
 }
Exemple #40
0
 public void DrawLinkDestinationAnnotation(SKRect rect, SKData value)
 {
     SkiaApi.sk_canvas_draw_link_destination_annotation(Handle, ref rect, value == null ? IntPtr.Zero : value.Handle);
 }
Exemple #41
0
 public static SKImageInfo DecodeBounds(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(codec.Info);
     }
 }