Example #1
0
		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);
		}
Example #2
0
        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));
            }
        }
Example #3
0
        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.");
        }
Example #4
0
        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));
            }
        }
Example #5
0
 public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc)
 {
     return(InstallPixels(info, pixels, rowBytes, releaseProc, null));
 }
Example #6
0
 public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
 {
     return(InstallPixels(info, pixels, rowBytes, releaseProc, context));
 }
Example #7
0
 public SKBitmapReleaseDelegateContext(SKBitmapReleaseDelegate releaseProc, object context)
 {
     Release = releaseProc;
     Context = context;
 }
Example #8
0
        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));
            }
        }
Example #9
0
			public SKBitmapReleaseDelegateContext (SKBitmapReleaseDelegate releaseProc, object context)
			{
				Release = releaseProc;
				Context = context;
			}
Example #10
0
		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);
			}
		}