Inheritance: SKObject
Beispiel #1
0
		public static bool IsValid3DColorCube(SKData cubeData, int cubeDimension)
		{
			var minMemorySize = 4 * cubeDimension * cubeDimension * cubeDimension;
			return
				(cubeDimension >= MinColorCubeDimension) && (cubeDimension <= MaxColorCubeDimension) &&
				(null != cubeData) && (cubeData.Size >= minMemorySize);
		}
Beispiel #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);
		}
Beispiel #3
0
		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));
		}
Beispiel #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);
        }
Beispiel #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));
     }
 }
Beispiel #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));
            }
        }
Beispiel #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));
                    }
            }
        }
Beispiel #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);
                    }
            }
        }
Beispiel #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));
            }
        }
Beispiel #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));
        }
Beispiel #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));
                    }
                }
        }
Beispiel #12
0
 public static SKImage FromData(SKData data)
 {
     return(FromEncodedData(data));
 }
Beispiel #13
0
 public static SKImage FromData(SKData data, SKRectI subset)
 {
     return(FromEncodedData(data, subset));
 }
Beispiel #14
0
        // Serialize

        public SKData Serialize() =>
        SKData.GetObject(SkiaApi.sk_picture_serialize_to_data(Handle));
Beispiel #15
0
 public MyUnmanagedMemoryStream(SKData host) : base((byte *)host.Data, host.Size)
 {
     this.host = host;
 }
Beispiel #16
0
 public static SKBitmap Decode(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(Decode(codec));
     }
 }
Beispiel #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));
		}
Beispiel #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.");
			}
		}
Beispiel #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;
			}
		}
Beispiel #20
0
            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);

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

        public static SKCodec Create(SKData data)
        {
            if (data == null)
                throw new ArgumentNullException(nameof(data)); }
Beispiel #22
0
 public SKMemoryStream(SKData data)
     : this(SkiaApi.sk_memorystream_new_with_skdata(data))
 {
 }
Beispiel #23
0
 public SKData DetachAsData()
 {
     return(SKData.GetObject(SkiaApi.sk_dynamicmemorywstream_detach_as_data(Handle)));
 }
Beispiel #24
0
 public extern static sk_stream_memorystream_t sk_memorystream_new_with_skdata(SKData data);
Beispiel #25
0
 public static SKTypeface FromData(SKData data, int index = 0)
 {
     return(SKTypeface.FromStream(new SKMemoryStream(data), index));
 }
Beispiel #26
0
 public unsafe SKDataStream(SKData host, bool disposeHost = false)
     : base((byte*)host.Data, host.Size)
 {
     this.host = host;
     this.disposeHost = disposeHost;
 }
Beispiel #27
0
		public extern static sk_stream_memorystream_t sk_memorystream_new_with_skdata(SKData data);
Beispiel #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
        }
Beispiel #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);
 }
Beispiel #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);
			}
		}
Beispiel #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);
 }
Beispiel #32
0
 public static SKImage FromPixels(SKImageInfo info, SKData data) =>
 FromPixels(info, data, info.RowBytes);
 private SKColorFilter ToColorFilter(SKData uniforms) =>
 ToColorFilter(uniforms, null);
Beispiel #34
0
 static SKData()
 {
     empty = new SKDataStatic(SkiaApi.sk_data_new_empty());
 }
Beispiel #35
0
 public SKData Encode() =>
 SKData.GetObject(SkiaApi.sk_image_encode(Handle));
Beispiel #36
0
 public unsafe SKDataStream(SKData host, bool disposeHost = false)
     : base((byte *)host.Data, host.Size)
 {
     this.host        = host;
     this.disposeHost = disposeHost;
 }
Beispiel #37
0
 public SKData Encode(SKEncodedImageFormat format, int quality)
 {
     return(SKData.GetObject(SkiaApi.sk_image_encode_specific(Handle, format, quality)));
 }
Beispiel #38
0
 public void DrawUrlAnnotation(SKRect rect, SKData value)
 {
     SkiaApi.sk_canvas_draw_url_annotation(Handle, ref rect, value == null ? IntPtr.Zero : value.Handle);
 }
Beispiel #39
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     host = null;
 }
Beispiel #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);
 }
Beispiel #41
0
 public static SKImageInfo DecodeBounds(SKData data)
 {
     using (var codec = SKCodec.Create(data)) {
         return(codec.Info);
     }
 }