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); }
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)); }
public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, SKSurfaceProps props) => Create (new SKImageInfo (width, height, colorType, alphaType), props);
public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha) { return(FromAdoptedTexture(context, texture, origin, colorType, alpha, null)); }
public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha) { return(FromTexture(context, desc, alpha, null, null)); }
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))); }
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))); } }
public static SKImage FromTexture(GRRecordingContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha) => FromTexture(context, texture, origin, colorType, alpha, null, null, null);
public static SKImage FromAdoptedTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace) => FromAdoptedTexture((GRRecordingContext)context, texture, origin, colorType, alpha, colorspace);
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)) {
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)); }
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)); } }
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)); }
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))); } }
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)); }
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))); }
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))); }
public SKPixmap WithAlphaType(SKAlphaType newAlphaType) { return(new SKPixmap(Info.WithAlphaType(newAlphaType), GetPixels(), RowBytes)); }
public static SKImage FromTexture(GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc) { return(FromTexture(context, desc, alpha, releaseProc, null)); }
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);
public SKBitmap (int width, int height, SKColorType colorType, SKAlphaType alphaType) : this (new SKImageInfo (width, height, colorType, alphaType)) { }
public static SKSurface Create(int width, int height, SKColorType colorType, SKAlphaType alphaType) => Create(new SKImageInfo(width, height, colorType, alphaType));
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);
public SKBitmap(int width, int height, SKColorType colorType, SKAlphaType alphaType) : this(new SKImageInfo(width, height, colorType, alphaType)) { }
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)