protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "SKImageSource") { SkiaSharp.SKImage Temp = (Element as ResumeApp.CustomElements.SKImage).SKImageSource; if (Temp != null) { if (counter++ == 10) { Task.Run(() => { GC.Collect(); counter = 0; }); } ThisImage = AndroidExtensions.ToBitmap(SKBitmap.FromImage(Temp)); if (ThisImage != null) { Xamarin.Essentials.MainThread.BeginInvokeOnMainThread(() => { Control.SetImageBitmap(ThisImage); Control.Invalidate(); }); } else { } } } }
// Draw*NinePatch public void DrawBitmapNinePatch(SKBitmap bitmap, SKRectI center, SKRect dst, SKPaint paint = null) { using var image = SKImage.FromBitmap(bitmap); DrawImageNinePatch(image, center, dst, paint); }
// CreateImage public static SKImageFilter CreateImage(SKImage image) { if (image == null) throw new ArgumentNullException(nameof(image)); return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_image_source_default(image.Handle)); }
// DrawImage public void DrawImage(SKImage image, SKPoint p, SKPaint paint = null) { DrawImage(image, p.X, p.Y, paint); }
public SKImage Snapshot() => SKImage.GetObject(SkiaApi.sk_surface_new_image_snapshot(Handle));
public SKImage Snapshot(SKRectI bounds) => SKImage.GetObject(SkiaApi.sk_surface_new_image_snapshot_with_crop(Handle, &bounds));
public static SKImageFilter CreateImage(SKImage image, SKRect src, SKRect dst, SKFilterQuality filterQuality) { if (image == null) throw new ArgumentNullException(nameof(image)); return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_image_source(image.Handle, &src, &dst, filterQuality)); }
// Draw*Lattice public void DrawBitmapLattice(SKBitmap bitmap, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null) { using var image = SKImage.FromBitmap(bitmap); DrawImageLattice(image, xDivs, yDivs, dst, paint); }
public void DrawBitmap(SKBitmap bitmap, float x, float y, SKPaint paint = null) { using var image = SKImage.FromBitmap(bitmap); DrawImage(image, x, y, paint); }
public void DrawBitmap(SKBitmap bitmap, SKRect source, SKRect dest, SKPaint paint = null) { using var image = SKImage.FromBitmap(bitmap); DrawImage(image, source, dest, paint); }
public void DrawAtlas(SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint) => DrawAtlas(atlas, sprites, transforms, colors, mode, &cullRect, paint);
// DrawAtlas public void DrawAtlas(SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint) => DrawAtlas(atlas, sprites, transforms, null, SKBlendMode.Dst, null, paint);
public void DrawBitmapLattice(SKBitmap bitmap, SKLattice lattice, SKRect dst, SKPaint paint = null) { using var image = SKImage.FromBitmap(bitmap); DrawImageLattice(image, lattice, dst, paint); }
public void DrawImageLattice(SKImage image, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null) { if (image == null) throw new ArgumentNullException (nameof (image)); if (xDivs == null) throw new ArgumentNullException (nameof (xDivs)); if (yDivs == null) throw new ArgumentNullException (nameof (yDivs)); SkiaApi.sk_canvas_draw_image_lattice (Handle, image.Handle, xDivs, xDivs.Length, yDivs, yDivs.Length, ref dst, paint == null ? IntPtr.Zero : paint.Handle); }
// CreateImage public static SKShader CreateImage (SKImage src) => CreateImage (src, SKShaderTileMode.Clamp, SKShaderTileMode.Clamp);
public void DrawImage(SKImage image, SKRect source, SKRect dest, SKPaint paint = null) { if (image == null) throw new ArgumentNullException (nameof (image)); SkiaApi.sk_canvas_draw_image_rect (Handle, image.Handle, ref source, ref dest, paint == null ? IntPtr.Zero : paint.Handle); }
public void DrawImage(SKImage image, float x, float y, SKPaint paint = null) { if (image == null) throw new ArgumentNullException (nameof (image)); SkiaApi.sk_canvas_draw_image (Handle, image.Handle, x, y, paint == null ? IntPtr.Zero : paint.Handle); }
public void DrawImageLattice (SKImage image, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null) { var lattice = new SKLattice { Bounds = null, Flags = null, XDivs = xDivs, YDivs = yDivs }; DrawImageLattice (image, lattice, dst, paint); }
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); }
public unsafe void DrawImageLattice (SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null) { if (image == null) throw new ArgumentNullException (nameof (image)); if (lattice.XDivs == null) throw new ArgumentNullException (nameof (lattice.XDivs)); if (lattice.YDivs == null) throw new ArgumentNullException (nameof (lattice.YDivs)); fixed (int* x = lattice.XDivs) fixed (int* y = lattice.YDivs) fixed (SKLatticeFlags* f = lattice.Flags) { var nativeLattice = new SKLatticeInternal { fBounds = null, fFlags = f, fXCount = lattice.XDivs.Length, fXDivs = x, fYCount = lattice.YDivs.Length, fYDivs = y, }; if (lattice.Bounds != null) { var bounds = lattice.Bounds.Value; nativeLattice.fBounds = &bounds; } SkiaApi.sk_canvas_draw_image_lattice (Handle, image.Handle, ref nativeLattice, ref dst, paint == null ? IntPtr.Zero : paint.Handle); } }