public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc, object context) { var cinfo = SKImageInfoNative.FromManaged (ref info); var del = releaseProc != null && context != null ? new SKBitmapReleaseDelegate ((addr, _) => releaseProc (addr, context)) : releaseProc; var proxy = DelegateProxies.Create (del, DelegateProxies.SKBitmapReleaseDelegateProxy, out _, out var ctx); return SkiaApi.sk_bitmap_install_pixels (Handle, &cinfo, (void*)pixels, (IntPtr)rowBytes, proxy, (void*)ctx); }
public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc, object context) { var cinfo = SKImageInfoNative.FromManaged(ref info); if (releaseProc == null) { return(SkiaApi.sk_bitmap_install_pixels(Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero)); } else { var ctx = new NativeDelegateContext(context, releaseProc); return(SkiaApi.sk_bitmap_install_pixels(Handle, ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext)); } }
public void ReleaseBitmapPixelsWasInvoked() { bool released = false; var onRelease = new SKBitmapReleaseDelegate((addr, ctx) => { Marshal.FreeCoTaskMem(addr); released = true; }); using (var bitmap = new SKBitmap()) { var info = new SKImageInfo(1, 1); var pixels = Marshal.AllocCoTaskMem(info.BytesSize); bitmap.InstallPixels(info, pixels, info.RowBytes, null, onRelease, "RELEASING!"); } Assert.True(released, "The SKBitmapReleaseDelegate was not called."); }
public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context) { IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle; if (releaseProc == null) { return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero)); } else { var ctx = new NativeDelegateContext(context, releaseProc); return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, releaseDelegate, ctx.NativeContext)); } }
public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc) { return(InstallPixels(info, pixels, rowBytes, releaseProc, null)); }
public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context) { return(InstallPixels(info, pixels, rowBytes, releaseProc, context)); }
public SKBitmapReleaseDelegateContext(SKBitmapReleaseDelegate releaseProc, object context) { Release = releaseProc; Context = context; }
public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context) { IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle; if (releaseProc == null) { return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero)); } else { var del = Marshal.GetFunctionPointerForDelegate(releaseDelegate); var ctx = new SKBitmapReleaseDelegateContext(releaseProc, context); var ctxPtr = ctx.Wrap(); return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, del, ctxPtr)); } }
public SKBitmapReleaseDelegateContext (SKBitmapReleaseDelegate releaseProc, object context) { Release = releaseProc; Context = context; }
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context) { IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle; if (releaseProc == null) { return SkiaApi.sk_bitmap_install_pixels (Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero); } else { var del = Marshal.GetFunctionPointerForDelegate (releaseDelegate); var ctx = new SKBitmapReleaseDelegateContext (releaseProc, context); var ctxPtr = ctx.Wrap (); return SkiaApi.sk_bitmap_install_pixels (Handle, ref info, pixels, (IntPtr)rowBytes, ct, del, ctxPtr); } }