Beispiel #1
6
		public void Erase (SKColor color, SKRectI rect)
		{
			SkiaApi.sk_bitmap_erase_rect (Handle, color, ref rect);
		}
Beispiel #2
0
		public static SKImage FromData (SKData data, SKRectI subset)
		{
			if (data == null)
				throw new ArgumentNullException (nameof (data));
			var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, ref subset);
			return GetObject<SKImage> (handle);
		}
Beispiel #3
0
 public bool Erase(SKColorF color, SKRectI subset) =>
 SkiaApi.sk_pixmap_erase_color4f(Handle, &color, &subset);
Beispiel #4
0
 public bool Intersects(SKRectI rect) =>
 SkiaApi.sk_region_intersects_rect(Handle, &rect);
Beispiel #5
0
 public SKImage ApplyImageFilter(GRContext context, SKImageFilter filter, SKRectI subset, SKRectI clipBounds, out SKRectI outSubset, out SKPointI outOffset) =>
 ApplyImageFilter((GRRecordingContext)context, filter, subset, clipBounds, out outSubset, out outOffset);
Beispiel #6
0
 public bool GetValidSubset(ref SKRectI desiredSubset)
 {
     return(SkiaApi.sk_codec_get_valid_subset(Handle, ref desiredSubset));
 }
Beispiel #7
0
 public static SKImageFilter CreateAlphaThreshold(SKRectI region, float innerThreshold, float outerThreshold, SKImageFilter input = null)
 {
     return(new SKImageFilter(SkiaApi.sk_imagefilter_new_alpha_threshold(ref region, innerThreshold, outerThreshold, input == null ? IntPtr.Zero : input.Handle)));
 }
Beispiel #8
0
 public bool GetClipDeviceBounds(ref SKRectI bounds)
 {
     return(SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds));
 }
Beispiel #9
0
		public SKCodecOptions (SKZeroInitialized zeroInitialized) {
			this.zeroInitialized = zeroInitialized;
			this.subset = SKRectI.Empty;
			this.hasSubset = false;
		}
Beispiel #10
0
 public bool SetRect(SKRectI rect)
 {
     return(SkiaApi.sk_region_set_rect(Handle, ref rect));
 }
Beispiel #11
0
        // QuickReject

        public bool QuickReject(SKRectI rect) =>
        SkiaApi.sk_region_quick_reject_rect(Handle, &rect);
Beispiel #12
0
		public bool SetRect(SKRectI rect)
		{
			return SkiaApi.sk_region_set_rect(Handle, ref rect); 
		}
Beispiel #13
0
        // QuickContains

        public bool QuickContains(SKRectI rect) =>
        SkiaApi.sk_region_quick_contains(Handle, &rect);
Beispiel #14
0
 public bool Contains(SKRectI rect) =>
 SkiaApi.sk_region_contains_rect(Handle, &rect);
Beispiel #15
0
		public bool GetValidSubset (ref SKRectI desiredSubset)
		{
			return SkiaApi.sk_codec_get_valid_subset (Handle, ref desiredSubset);
		}
Beispiel #16
0
        public SKImage ApplyImageFilter(SKImageFilter filter, SKRectI subset, SKRectI clipBounds, out SKRectI outSubset, out SKPointI outOffset)
        {
            if (filter == null)
                throw new ArgumentNullException(nameof(filter));

            fixed(SKRectI *os = &outSubset)
            fixed(SKPointI * oo = &outOffset)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_make_with_filter(Handle, filter.Handle, &subset, &clipBounds, os, oo)));
            }
        }
Beispiel #17
0
        // ApplyImageFilter

        public SKImage ApplyImageFilter(SKImageFilter filter, SKRectI subset, SKRectI clipBounds, out SKRectI outSubset, out SKPoint outOffset)
        {
            var image = ApplyImageFilter(filter, subset, clipBounds, out outSubset, out SKPointI outOffsetActual);

            outOffset = outOffsetActual;
            return(image);
        }
Beispiel #18
0
 public bool SetRect(SKRectI rect) =>
 SkiaApi.sk_region_set_rect(Handle, &rect);
Beispiel #19
0
 public SKRegion(SKRectI rect)
     : this()
 {
     SetRect(rect);
 }
Beispiel #20
0
        public void DrawBitmapNinePatch(SKBitmap bitmap, SKRectI center, SKRect dst, SKPaint paint = null)
        {
            if (bitmap == null)
                throw new ArgumentNullException (nameof (bitmap));
            // the "center" rect must fit inside the bitmap "rect"
            if (!SKRect.Create (bitmap.Info.Size).Contains (center))
                throw new ArgumentOutOfRangeException (nameof (center));

            var xDivs = new [] { center.Left, center.Right };
            var yDivs = new [] { center.Top, center.Bottom };
            DrawBitmapLattice (bitmap, xDivs, yDivs, dst, paint);
        }
 public bool Op(SKRectI rect, SKRegionOperation op)
 {
     return(SkiaApi.sk_region_op(Handle, rect.Left, rect.Top, rect.Right, rect.Bottom, op));
 }
Beispiel #22
0
 public bool GetDeviceClipBounds(out SKRectI bounds)
 {
     return(SkiaApi.sk_canvas_get_device_clip_bounds(Handle, out bounds));
 }
Beispiel #23
0
		public static void BitmapLattice (SKCanvas canvas, int width, int height)
		{
			canvas.Clear (SKColors.White);

			var assembly = typeof (Demos).GetTypeInfo ().Assembly;
			var imageName = assembly.GetName ().Name + ".nine-patch.png";

			// load the image from the embedded resource stream
			using (var resource = assembly.GetManifestResourceStream (imageName))
			using (var stream = new SKManagedStream (resource))
			using (var bitmap = SKBitmap.Decode (stream))
			{
				var patchCenter = new SKRectI (33, 33, 256 - 33, 256 - 33);

				// 2x3 for portrait, or 3x2 for landscape
				var land = width > height;
				var min = land ? Math.Min (width / 3f, height / 2f) : Math.Min (width / 2f, height / 3f);
				var wide = SKRect.Inflate (SKRect.Create (0, land ? min : (min * 2f), min * 2f, min), -6, -6);
				var tall = SKRect.Inflate (SKRect.Create (land ? (min * 2f) : min, 0, min, min * 2f), -6, -6);
				var square = SKRect.Inflate (SKRect.Create (0, 0, min, min), -6, -6);
				var text = SKRect.Create (land ? min : 0, land ? 0 : min, min, min / 5f);
				text.Offset (text.Width / 2f, text.Height * 1.5f);
				text.Right = text.Left;

				// draw the bitmaps
				canvas.DrawBitmapNinePatch (bitmap, patchCenter, square);
				canvas.DrawBitmapNinePatch (bitmap, patchCenter, tall);
				canvas.DrawBitmapNinePatch (bitmap, patchCenter, wide);

				// describe what we see
				using (var paint = new SKPaint ())
				{
					paint.TextAlign = SKTextAlign.Center;
					paint.TextSize = text.Height * 0.75f;

					canvas.DrawText ("The corners", text.Left, text.Top, paint);
					text.Offset (0, text.Height);
					canvas.DrawText ("should always", text.Left, text.Top, paint);
					text.Offset (0, text.Height);
					canvas.DrawText ("be square", text.Left, text.Top, paint);
				}
			}
		}
Beispiel #24
0
 public void Erase(SKColor color, SKRectI rect)
 {
     SkiaApi.sk_bitmap_erase_rect(Handle, (uint)color, &rect);
 }
Beispiel #25
0
		public extern static bool sk_codec_get_valid_subset(sk_codec_t codec, ref SKRectI desiredSubset);
Beispiel #26
0
 public static SKImage FromData(SKData data, SKRectI subset)
 {
     return(FromEncodedData(data, subset));
 }
Beispiel #27
0
		public extern static void sk_bitmap_erase_rect(sk_bitmap_t cbitmap, SKColor color, ref SKRectI rect);
Beispiel #28
0
 public SKImage ApplyImageFilter(SKImageFilter filter, SKRectI subset, SKRectI clipBounds, out SKRectI outSubset, out SKPoint outOffset)
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
     return(GetObject <SKImage> (SkiaApi.sk_image_make_with_filter(Handle, filter.Handle, ref subset, ref clipBounds, out outSubset, out outOffset)));
 }
Beispiel #29
0
		public extern static bool sk_region_intersects(sk_region_t r, SKRectI rect);
Beispiel #30
0
 public bool Erase(SKColor color, SKRectI subset)
 {
     return(SkiaApi.sk_pixmap_erase_color(Handle, (uint)color, &subset));
 }
Beispiel #31
0
		public extern static bool sk_region_set_rect(sk_region_t r, ref SKRectI rect);
Beispiel #32
0
 public void Erase(SKColor color, SKRectI rect)
 {
     SkiaApi.sk_bitmap_erase_rect(Handle, color, ref rect);
 }
Beispiel #33
0
		public extern static bool sk_canvas_get_clip_device_bounds(sk_canvas_t t, ref SKRectI cbounds);
Beispiel #34
0
		public bool Intersects(SKRectI rect)
		{
			return SkiaApi.sk_region_intersects(Handle, rect);
		}
Beispiel #35
0
		public extern static sk_image_t sk_image_new_from_encoded(sk_data_t encoded, ref SKRectI subset);
Beispiel #36
0
		public bool Op(SKRectI rect, SKRegionOperation op)
		{
			return SkiaApi.sk_region_op(Handle, rect.Left, rect.Top, rect.Right, rect.Bottom, op);
		}
Beispiel #37
0
		public extern static sk_imagefilter_t sk_imagefilter_new_alpha_threshold(ref SKRectI region, float innerThreshold, float outerThreshold, sk_imagefilter_t input /*NULL*/);
Beispiel #38
0
		public static SKImageFilter CreateAlphaThreshold(SKRectI region, float innerThreshold, float outerThreshold, SKImageFilter input = null)
		{
			return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_alpha_threshold(ref region, innerThreshold, outerThreshold, input == null ? IntPtr.Zero : input.Handle));
		}
Beispiel #39
0
 public bool Intersects(SKRectI rect)
 {
     return(SkiaApi.sk_region_intersects(Handle, rect));
 }
Beispiel #40
0
		public SKCodecOptions (SKZeroInitialized zeroInitialized, SKRectI subset) {
			this.zeroInitialized = zeroInitialized;
			this.subset = subset;
			this.hasSubset = true;
		}
Beispiel #41
0
 public SKImage Subset(SKRectI subset)
 {
     return(GetObject <SKImage> (SkiaApi.sk_image_make_subset(Handle, ref subset)));
 }
Beispiel #42
0
 public SKCodecOptions(SKRectI subset)
 {
     ZeroInitialized = SKZeroInitialized.No;
     Subset = subset;
 }
Beispiel #43
0
 public SKImage Snapshot(SKRectI bounds) =>
 SKImage.GetObject(SkiaApi.sk_surface_new_image_snapshot_with_crop(Handle, &bounds));
Beispiel #44
0
 private bool IntersectsWithInclusive(SKRectI r)
 {
     return
         !((left > r.right) || (right < r.left) ||
           (top > r.bottom) || (bottom < r.top));
 }
Beispiel #45
0
 public SKCodecOptions(SKZeroInitialized zeroInitialized, SKRectI subset)
 {
     ZeroInitialized = zeroInitialized;
     Subset = subset;
 }
Beispiel #46
0
 public bool Contains(SKRectI rect)
 {
     return
         (left <= rect.left) && (right >= rect.right) &&
         (top <= rect.top) && (bottom >= rect.bottom);
 }
Beispiel #47
0
 public bool IntersectsWith(SKRectI rect)
 {
     return
         !((left >= rect.right) || (right <= rect.left) ||
           (top >= rect.bottom) || (bottom <= rect.top));
 }
Beispiel #48
0
 public static SKRectI Union(SKRectI a, SKRectI b)
 {
     return new SKRectI(
         Math.Min(a.Left, b.Left),
         Math.Min(a.Top, b.Top),
         Math.Max(a.Right, b.Right),
         Math.Max(a.Bottom, b.Bottom));
 }
Beispiel #49
0
 public void Union(SKRectI rect)
 {
     this = SKRectI.Union(this, rect);
 }
Beispiel #50
0
 public void Intersect(SKRectI rect)
 {
     this = SKRectI.Intersect(this, rect);
 }
Beispiel #51
0
        public static SKRectI Intersect(SKRectI a, SKRectI b)
        {
            if (!a.IntersectsWithInclusive(b))
                return Empty;

            return new SKRectI(
                Math.Max(a.left, b.left),
                Math.Max(a.top, b.top),
                Math.Min(a.right, b.right),
                Math.Min(a.bottom, b.bottom));
        }
Beispiel #52
0
 public static SKRectI Inflate(SKRectI rect, int x, int y)
 {
     SKRectI r = new SKRectI(rect.left, rect.top, rect.right, rect.bottom);
     r.Inflate(x, y);
     return r;
 }
Beispiel #53
0
 public bool GetClipDeviceBounds(ref SKRectI bounds)
 {
     return SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds);
 }
Beispiel #54
-1
        public void DrawImageNinePatch(SKImage image, SKRectI center, SKRect dst, SKPaint paint = null)
        {
            if (image == null)
                throw new ArgumentNullException (nameof (image));
            // the "center" rect must fit inside the image "rect"
            if (!SKRect.Create (image.Width, image.Height).Contains (center))
                throw new ArgumentOutOfRangeException (nameof (center));

            var xDivs = new [] { center.Left, center.Right };
            var yDivs = new [] { center.Top, center.Bottom };
            DrawImageLattice (image, xDivs, yDivs, dst, paint);
        }