Exemple #1
6
		public void Erase (SKColor color, SKRectI rect)
		{
			SkiaApi.sk_bitmap_erase_rect (Handle, color, ref rect);
		}
Exemple #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);
		}
Exemple #3
0
 public bool Erase(SKColorF color, SKRectI subset) =>
 SkiaApi.sk_pixmap_erase_color4f(Handle, &color, &subset);
Exemple #4
0
 public bool Intersects(SKRectI rect) =>
 SkiaApi.sk_region_intersects_rect(Handle, &rect);
Exemple #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);
Exemple #6
0
 public bool GetValidSubset(ref SKRectI desiredSubset)
 {
     return(SkiaApi.sk_codec_get_valid_subset(Handle, ref desiredSubset));
 }
Exemple #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)));
 }
Exemple #8
0
 public bool GetClipDeviceBounds(ref SKRectI bounds)
 {
     return(SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds));
 }
Exemple #9
0
		public SKCodecOptions (SKZeroInitialized zeroInitialized) {
			this.zeroInitialized = zeroInitialized;
			this.subset = SKRectI.Empty;
			this.hasSubset = false;
		}
Exemple #10
0
 public bool SetRect(SKRectI rect)
 {
     return(SkiaApi.sk_region_set_rect(Handle, ref rect));
 }
Exemple #11
0
        // QuickReject

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

        public bool QuickContains(SKRectI rect) =>
        SkiaApi.sk_region_quick_contains(Handle, &rect);
Exemple #14
0
 public bool Contains(SKRectI rect) =>
 SkiaApi.sk_region_contains_rect(Handle, &rect);
Exemple #15
0
		public bool GetValidSubset (ref SKRectI desiredSubset)
		{
			return SkiaApi.sk_codec_get_valid_subset (Handle, ref desiredSubset);
		}
Exemple #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)));
            }
        }
Exemple #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);
        }
Exemple #18
0
 public bool SetRect(SKRectI rect) =>
 SkiaApi.sk_region_set_rect(Handle, &rect);
Exemple #19
0
 public SKRegion(SKRectI rect)
     : this()
 {
     SetRect(rect);
 }
Exemple #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));
 }
Exemple #22
0
 public bool GetDeviceClipBounds(out SKRectI bounds)
 {
     return(SkiaApi.sk_canvas_get_device_clip_bounds(Handle, out bounds));
 }
Exemple #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);
				}
			}
		}
Exemple #24
0
 public void Erase(SKColor color, SKRectI rect)
 {
     SkiaApi.sk_bitmap_erase_rect(Handle, (uint)color, &rect);
 }
Exemple #25
0
		public extern static bool sk_codec_get_valid_subset(sk_codec_t codec, ref SKRectI desiredSubset);
Exemple #26
0
 public static SKImage FromData(SKData data, SKRectI subset)
 {
     return(FromEncodedData(data, subset));
 }
Exemple #27
0
		public extern static void sk_bitmap_erase_rect(sk_bitmap_t cbitmap, SKColor color, ref SKRectI rect);
Exemple #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)));
 }
Exemple #29
0
		public extern static bool sk_region_intersects(sk_region_t r, SKRectI rect);
Exemple #30
0
 public bool Erase(SKColor color, SKRectI subset)
 {
     return(SkiaApi.sk_pixmap_erase_color(Handle, (uint)color, &subset));
 }
Exemple #31
0
		public extern static bool sk_region_set_rect(sk_region_t r, ref SKRectI rect);
Exemple #32
0
 public void Erase(SKColor color, SKRectI rect)
 {
     SkiaApi.sk_bitmap_erase_rect(Handle, color, ref rect);
 }
Exemple #33
0
		public extern static bool sk_canvas_get_clip_device_bounds(sk_canvas_t t, ref SKRectI cbounds);
Exemple #34
0
		public bool Intersects(SKRectI rect)
		{
			return SkiaApi.sk_region_intersects(Handle, rect);
		}
Exemple #35
0
		public extern static sk_image_t sk_image_new_from_encoded(sk_data_t encoded, ref SKRectI subset);
Exemple #36
0
		public bool Op(SKRectI rect, SKRegionOperation op)
		{
			return SkiaApi.sk_region_op(Handle, rect.Left, rect.Top, rect.Right, rect.Bottom, op);
		}
Exemple #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*/);
		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));
		}
Exemple #39
0
 public bool Intersects(SKRectI rect)
 {
     return(SkiaApi.sk_region_intersects(Handle, rect));
 }
Exemple #40
0
		public SKCodecOptions (SKZeroInitialized zeroInitialized, SKRectI subset) {
			this.zeroInitialized = zeroInitialized;
			this.subset = subset;
			this.hasSubset = true;
		}
Exemple #41
0
 public SKImage Subset(SKRectI subset)
 {
     return(GetObject <SKImage> (SkiaApi.sk_image_make_subset(Handle, ref subset)));
 }
Exemple #42
0
 public SKCodecOptions(SKRectI subset)
 {
     ZeroInitialized = SKZeroInitialized.No;
     Subset = subset;
 }
Exemple #43
0
 public SKImage Snapshot(SKRectI bounds) =>
 SKImage.GetObject(SkiaApi.sk_surface_new_image_snapshot_with_crop(Handle, &bounds));
Exemple #44
0
 private bool IntersectsWithInclusive(SKRectI r)
 {
     return
         !((left > r.right) || (right < r.left) ||
           (top > r.bottom) || (bottom < r.top));
 }
Exemple #45
0
 public SKCodecOptions(SKZeroInitialized zeroInitialized, SKRectI subset)
 {
     ZeroInitialized = zeroInitialized;
     Subset = subset;
 }
Exemple #46
0
 public bool Contains(SKRectI rect)
 {
     return
         (left <= rect.left) && (right >= rect.right) &&
         (top <= rect.top) && (bottom >= rect.bottom);
 }
Exemple #47
0
 public bool IntersectsWith(SKRectI rect)
 {
     return
         !((left >= rect.right) || (right <= rect.left) ||
           (top >= rect.bottom) || (bottom <= rect.top));
 }
Exemple #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));
 }
Exemple #49
0
 public void Union(SKRectI rect)
 {
     this = SKRectI.Union(this, rect);
 }
Exemple #50
0
 public void Intersect(SKRectI rect)
 {
     this = SKRectI.Intersect(this, rect);
 }
Exemple #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));
        }
Exemple #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;
 }
Exemple #53
0
 public bool GetClipDeviceBounds(ref SKRectI bounds)
 {
     return SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds);
 }
Exemple #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);
        }