public void Erase (SKColor color, SKRectI rect) { SkiaApi.sk_bitmap_erase_rect (Handle, color, ref rect); }
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); }
public bool Erase(SKColorF color, SKRectI subset) => SkiaApi.sk_pixmap_erase_color4f(Handle, &color, &subset);
public bool Intersects(SKRectI rect) => SkiaApi.sk_region_intersects_rect(Handle, &rect);
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);
public bool GetValidSubset(ref SKRectI desiredSubset) { return(SkiaApi.sk_codec_get_valid_subset(Handle, ref desiredSubset)); }
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))); }
public bool GetClipDeviceBounds(ref SKRectI bounds) { return(SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds)); }
public SKCodecOptions (SKZeroInitialized zeroInitialized) { this.zeroInitialized = zeroInitialized; this.subset = SKRectI.Empty; this.hasSubset = false; }
public bool SetRect(SKRectI rect) { return(SkiaApi.sk_region_set_rect(Handle, ref rect)); }
// QuickReject public bool QuickReject(SKRectI rect) => SkiaApi.sk_region_quick_reject_rect(Handle, &rect);
public bool SetRect(SKRectI rect) { return SkiaApi.sk_region_set_rect(Handle, ref rect); }
// QuickContains public bool QuickContains(SKRectI rect) => SkiaApi.sk_region_quick_contains(Handle, &rect);
public bool Contains(SKRectI rect) => SkiaApi.sk_region_contains_rect(Handle, &rect);
public bool GetValidSubset (ref SKRectI desiredSubset) { return SkiaApi.sk_codec_get_valid_subset (Handle, ref desiredSubset); }
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))); } }
// 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); }
public bool SetRect(SKRectI rect) => SkiaApi.sk_region_set_rect(Handle, &rect);
public SKRegion(SKRectI rect) : this() { SetRect(rect); }
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)); }
public bool GetDeviceClipBounds(out SKRectI bounds) { return(SkiaApi.sk_canvas_get_device_clip_bounds(Handle, out bounds)); }
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); } } }
public void Erase(SKColor color, SKRectI rect) { SkiaApi.sk_bitmap_erase_rect(Handle, (uint)color, &rect); }
public extern static bool sk_codec_get_valid_subset(sk_codec_t codec, ref SKRectI desiredSubset);
public static SKImage FromData(SKData data, SKRectI subset) { return(FromEncodedData(data, subset)); }
public extern static void sk_bitmap_erase_rect(sk_bitmap_t cbitmap, SKColor color, ref SKRectI rect);
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))); }
public extern static bool sk_region_intersects(sk_region_t r, SKRectI rect);
public bool Erase(SKColor color, SKRectI subset) { return(SkiaApi.sk_pixmap_erase_color(Handle, (uint)color, &subset)); }
public extern static bool sk_region_set_rect(sk_region_t r, ref SKRectI rect);
public void Erase(SKColor color, SKRectI rect) { SkiaApi.sk_bitmap_erase_rect(Handle, color, ref rect); }
public extern static bool sk_canvas_get_clip_device_bounds(sk_canvas_t t, ref SKRectI cbounds);
public bool Intersects(SKRectI rect) { return SkiaApi.sk_region_intersects(Handle, rect); }
public extern static sk_image_t sk_image_new_from_encoded(sk_data_t encoded, ref SKRectI subset);
public bool Op(SKRectI rect, SKRegionOperation op) { return SkiaApi.sk_region_op(Handle, rect.Left, rect.Top, rect.Right, rect.Bottom, op); }
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)); }
public bool Intersects(SKRectI rect) { return(SkiaApi.sk_region_intersects(Handle, rect)); }
public SKCodecOptions (SKZeroInitialized zeroInitialized, SKRectI subset) { this.zeroInitialized = zeroInitialized; this.subset = subset; this.hasSubset = true; }
public SKImage Subset(SKRectI subset) { return(GetObject <SKImage> (SkiaApi.sk_image_make_subset(Handle, ref subset))); }
public SKCodecOptions(SKRectI subset) { ZeroInitialized = SKZeroInitialized.No; Subset = subset; }
public SKImage Snapshot(SKRectI bounds) => SKImage.GetObject(SkiaApi.sk_surface_new_image_snapshot_with_crop(Handle, &bounds));
private bool IntersectsWithInclusive(SKRectI r) { return !((left > r.right) || (right < r.left) || (top > r.bottom) || (bottom < r.top)); }
public SKCodecOptions(SKZeroInitialized zeroInitialized, SKRectI subset) { ZeroInitialized = zeroInitialized; Subset = subset; }
public bool Contains(SKRectI rect) { return (left <= rect.left) && (right >= rect.right) && (top <= rect.top) && (bottom >= rect.bottom); }
public bool IntersectsWith(SKRectI rect) { return !((left >= rect.right) || (right <= rect.left) || (top >= rect.bottom) || (bottom <= rect.top)); }
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)); }
public void Union(SKRectI rect) { this = SKRectI.Union(this, rect); }
public void Intersect(SKRectI rect) { this = SKRectI.Intersect(this, rect); }
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)); }
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; }
public bool GetClipDeviceBounds(ref SKRectI bounds) { return SkiaApi.sk_canvas_get_clip_device_bounds(Handle, ref bounds); }
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); }