Exemple #1
0
 public SKImageInfo(int width, int height)
 {
     this.width = width;
     this.height = height;
     this.colorType = PlatformColorType;
     this.alphaType = SKAlphaType.Premul;
 }
        public static SKBitmap?ToBitmap(this SKPicture skPicture, SKColor background, float scaleX, float scaleY, SKColorType skColorType, SKAlphaType skAlphaType)
#endif
        {
            float width  = skPicture.CullRect.Width * scaleX;
            float height = skPicture.CullRect.Height * scaleY;

            if (width > 0 && height > 0)
            {
#if USE_COLORSPACE
                var skImageInfo = new SKImageInfo((int)width, (int)height, skColorType, skAlphaType, skColorSpace);
#else
                var skImageInfo = new SKImageInfo((int)width, (int)height, skColorType, skAlphaType);
#endif
                var skBitmap = new SKBitmap(skImageInfo);
                using var skCanvas = new SKCanvas(skBitmap);
                Draw(skPicture, background, scaleX, scaleY, skCanvas);
                return(skBitmap);
            }
            return(null);
        }
Exemple #3
0
        public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var texture = new GRBackendTexture(desc);

            return(FromTexture(context, texture, desc.Origin, desc.Config.ToColorType(), alpha, null, releaseProc, releaseContext));
        }
Exemple #4
0
		public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, SKSurfaceProps props) => Create (new SKImageInfo (width, height, colorType, alphaType), props);
Exemple #5
0
 public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha)
 {
     return(FromAdoptedTexture(context, texture, origin, colorType, alpha, null));
 }
Exemple #6
0
 public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha)
 {
     return(FromTexture(context, desc, alpha, null, null));
 }
Exemple #7
0
        public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            var cs  = colorspace == null ? IntPtr.Zero : colorspace.Handle;
            var del = releaseProc != null && releaseContext != null
                                ? new SKImageTextureReleaseDelegate((_) => releaseProc(releaseContext))
                                : releaseProc;
            var proxy = DelegateProxies.Create(del, DelegateProxies.SKImageTextureReleaseDelegateProxy, out _, out var ctx);

            return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs, proxy, (void *)ctx)));
        }
Exemple #8
0
        public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;

            if (releaseProc == null)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs, IntPtr.Zero, IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(releaseContext, releaseProc);
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs, textureReleaseDelegate, ctx.NativeContext)));
            }
        }
Exemple #9
0
 public static SKImage FromTexture(GRRecordingContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha) =>
 FromTexture(context, texture, origin, colorType, alpha, null, null, null);
Exemple #10
0
 public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace) =>
 FromAdoptedTexture((GRRecordingContext)context, texture, origin, colorType, alpha, colorspace);
Exemple #11
0
 public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc, object releaseContext) =>
 FromTexture((GRRecordingContext)context, texture, origin, colorType, alpha, colorspace, releaseProc, releaseContext);
        public static bool ToImage(this SKPicture skPicture, Stream stream, SKColor background, SKEncodedImageFormat format, int quality, float scaleX, float scaleY, SKColorType skColorType, SKAlphaType skAlphaType)
        {
            using (var skBitmap = skPicture.ToBitmap(background, scaleX, scaleY, skColorType, skAlphaType))
            {
#endif
                if (skBitmap == null)
                {
                    return(false);
                }
                using var skImage = SKImage.FromBitmap(skBitmap);
                using var skData  = skImage.Encode(format, quality);
                if (skData != null)
                {
                    skData.SaveTo(stream);
                    return(true);
                }
            }
            return(false);
        }
 public static bool ToImage(this SKPicture skPicture, Stream stream, SKColor background, SKEncodedImageFormat format, int quality, float scaleX, float scaleY, SKColorType skColorType, SKAlphaType skAlphaType, SKColorSpace skColorSpace)
 {
     using (var skBitmap = skPicture.ToBitmap(background, scaleX, scaleY, skColorType, skAlphaType, skColorSpace))
     {
Exemple #14
0
        public static SKImage FromTexture(GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            var texture = new GRBackendTexture(desc);

            return(FromTexture(context, texture, desc.Origin, desc.Config.ToColorType(), alpha, null, releaseProc, releaseContext));
        }
Exemple #15
0
 public static SKImage FromAdoptedTexture(GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha)
 {
     unsafe {
         var h    = desc.TextureHandle;
         var hPtr = &h;
         var d    = new GRBackendTextureDesc {
             Flags         = desc.Flags,
             Origin        = desc.Origin,
             Width         = desc.Width,
             Height        = desc.Height,
             Config        = desc.Config,
             SampleCount   = desc.SampleCount,
             TextureHandle = (IntPtr)hPtr,
         };
         return(FromAdoptedTexture(context, d, alpha));
     }
 }
Exemple #16
0
 public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc)
 {
     return(FromTexture(context, texture, origin, colorType, alpha, colorspace, releaseProc, null));
 }
Exemple #17
0
        public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (releaseProc == null)
            {
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, ref desc, alpha, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)));
            }
            else
            {
                var ctx = new NativeDelegateContext(releaseContext, releaseProc);
                return(GetObject <SKImage> (SkiaApi.sk_image_new_from_texture(context.Handle, ref desc, alpha, IntPtr.Zero, textureReleaseDelegate, ctx.NativeContext)));
            }
        }
Exemple #18
0
        public static SKImage FromAdoptedTexture(GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha)
        {
            var texture = new GRBackendTexture(desc);

            return(FromAdoptedTexture(context, texture, desc.Origin, desc.Config.ToColorType(), alpha, null));
        }
Exemple #19
0
        public static SKImage FromAdoptedTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(GetObject <SKImage> (SkiaApi.sk_image_new_from_adopted_texture(context.Handle, ref desc, alpha, IntPtr.Zero)));
        }
Exemple #20
0
        public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;

            return(GetObject <SKImage> (SkiaApi.sk_image_new_from_adopted_texture(context.Handle, texture.Handle, origin, colorType, alpha, cs)));
        }
Exemple #21
0
 public SKPixmap WithAlphaType(SKAlphaType newAlphaType)
 {
     return(new SKPixmap(Info.WithAlphaType(newAlphaType), GetPixels(), RowBytes));
 }
Exemple #22
0
 public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc)
 {
     return(FromTexture(context, desc, alpha, releaseProc, null));
 }
Exemple #23
0
 public static SKSurface Create(int width, int height, SKColorType colorType, SKAlphaType alphaType, IntPtr pixels, int rowBytes, SKSurfaceProps props) => Create(new SKImageInfo(width, height, colorType, alphaType), pixels, rowBytes, props);
Exemple #24
0
		public SKBitmap (int width, int height, SKColorType colorType, SKAlphaType alphaType)
			: this (new SKImageInfo (width, height, colorType, alphaType))
		{
		}
Exemple #25
0
 public static SKSurface Create(int width, int height, SKColorType colorType, SKAlphaType alphaType) => Create(new SKImageInfo(width, height, colorType, alphaType));
Exemple #26
0
		public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, IntPtr pixels, int rowBytes, SKSurfaceProps props) => Create (new SKImageInfo (width, height, colorType, alphaType), pixels, rowBytes, props);
Exemple #27
0
 public SKBitmap(int width, int height, SKColorType colorType, SKAlphaType alphaType)
     : this(new SKImageInfo(width, height, colorType, alphaType))
 {
 }
Exemple #28
0
 public SKImageInfo(int width, int height, SKColorType colorType, SKAlphaType alphaType)
 {
     this.width = width;
     this.height = height;
     this.colorType = colorType;
     this.alphaType = alphaType;
 }
 public static SKBitmap?ToBitmap(this SKPicture skPicture, SKColor background, float scaleX, float scaleY, SKColorType skColorType, SKAlphaType skAlphaType, SKColorSpace skColorSpace)