public static SKSurface Create(GRRecordingContext context, CoreAnimation.CAMetalLayer layer, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props, out CoreAnimation.ICAMetalDrawable drawable) { void *drawablePtr; var surface = GetObject(SkiaApi.sk_surface_new_metal_layer(context.Handle, (void *)layer.Handle, origin, sampleCount, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero, &drawablePtr)); drawable = ObjCRuntime.Runtime.GetINativeObject <CoreAnimation.ICAMetalDrawable> ((IntPtr)drawablePtr, true); return(surface); }
public static SKShader CreateLinearGradient(SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) => CreateLinearGradient(start, end, colors, colorspace, null, mode);
public static SKShader CreateRadialGradient(SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) => CreateRadialGradient(center, radius, colors, colorspace, null, mode);
public static SKSurface Create(GRContext context, GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin, SKColorType colorType, SKColorSpace colorspace) => Create(context, renderTarget, origin, colorType, colorspace, null);
public static SKSurface CreateAsRenderTarget(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace) => CreateAsRenderTarget(context, texture, origin, sampleCount, colorType, colorspace, null);
public static SKShader CreateSweepGradient(SKPoint center, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode tileMode, float startAngle, float endAngle) => CreateSweepGradient(center, colors, colorspace, null, tileMode, startAngle, endAngle);
public static SKShader CreateTwoPointConicalGradient(SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, SKShaderTileMode mode) => CreateTwoPointConicalGradient(start, startRadius, end, endRadius, colors, colorspace, null, mode);
static SKColorSpace() { srgb = new SKColorSpaceStatic(SkiaApi.sk_colorspace_new_srgb()); srgbLinear = new SKColorSpaceStatic(SkiaApi.sk_colorspace_new_srgb_linear()); }
public static SKImage FromTexture(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace) { return(FromTexture(context, texture, origin, colorType, alpha, colorspace, 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; 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 SKImageInfo(int width, int height, SKColorType colorType, SKAlphaType alphaType, SKColorSpace colorspace) { this.width = width; this.height = height; this.colorType = colorType; this.alphaType = alphaType; this.colorSpace = colorspace; }
public bool CopyTo(SKBitmap destination, SKColorType colorType) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (!CanCopyTo(colorType)) { return(false); } var srcPM = PeekPixels(); if (srcPM == null) { return(false); } var dstInfo = srcPM.Info.WithColorType(colorType); switch (colorType) { case SKColorType.Rgb565: // CopyTo() is not strict on alpha type. Here we set the src to opaque to allow // the call to ReadPixels() to succeed and preserve this lenient behavior. if (srcPM.AlphaType != SKAlphaType.Opaque) { srcPM = srcPM.WithAlphaType(SKAlphaType.Opaque); } dstInfo.AlphaType = SKAlphaType.Opaque; break; case SKColorType.RgbaF16: // The caller does not have an opportunity to pass a dst color space. // Assume that they want linear sRGB. dstInfo.ColorSpace = SKColorSpace.CreateSrgbLinear(); if (srcPM.ColorSpace == null) { // We can't do a sane conversion to F16 without a dst color space. // Guess sRGB in this case. srcPM = srcPM.WithColorSpace(SKColorSpace.CreateSrgb()); } break; } var tmpDst = new SKBitmap(); if (!tmpDst.TryAllocPixels(dstInfo)) { return(false); } var dstPM = tmpDst.PeekPixels(); if (dstPM == null) { return(false); } // We can't do a sane conversion from F16 without a src color space. Guess sRGB in this case. if (srcPM.ColorType == SKColorType.RgbaF16 && dstPM.ColorSpace == null) { dstPM = dstPM.WithColorSpace(SKColorSpace.CreateSrgb()); } // ReadPixels does not yet support color spaces with parametric transfer functions. This // works around that restriction when the color spaces are equal. if (colorType != SKColorType.RgbaF16 && srcPM.ColorType != SKColorType.RgbaF16 && dstPM.ColorSpace == srcPM.ColorSpace) { dstPM = dstPM.WithColorSpace(null); srcPM = srcPM.WithColorSpace(null); } if (!srcPM.ReadPixels(dstPM)) { return(false); } destination.Swap(tmpDst); return(true); }
public static SKSurface Create(GRRecordingContext context, MetalKit.MTKView view, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props) => GetObject(SkiaApi.sk_surface_new_metal_view(context.Handle, (void *)view.Handle, origin, sampleCount, colorType.ToNative(), colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero));
public static SKSurface Create(GRRecordingContext context, MetalKit.MTKView view, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace) => Create(context, view, origin, sampleCount, colorType, colorspace, null);
public static SKShader CreateSweepGradient(SKPoint center, SKColorF[] colors, SKColorSpace colorspace) => CreateSweepGradient(center, colors, colorspace, null, SKShaderTileMode.Clamp, 0, 360);
public SKImageInfo(int width, int height, SKColorType colorType, SKAlphaType alphaType, SKColorSpace colorspace) { Width = width; Height = height; ColorType = colorType; AlphaType = alphaType; ColorSpace = colorspace; }
public static SKShader CreateSweepGradient(SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKMatrix localMatrix) => CreateSweepGradient(center, colors, colorspace, colorPos, SKShaderTileMode.Clamp, 0, 360, localMatrix);
public static SKImage FromTexture(GRRecordingContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc) => FromTexture(context, texture, origin, colorType, alpha, colorspace, releaseProc, null);
public static SKShader CreateSweepGradient(SKPoint center, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode tileMode, float startAngle, float endAngle) { if (colors == null) { throw new ArgumentNullException(nameof(colors)); } if (colorPos != null && colors.Length != colorPos.Length) { throw new ArgumentException("The number of colors must match the number of color positions."); fixed(SKColorF *c = colors) fixed(float *cp = colorPos) { return(GetObject(SkiaApi.sk_shader_new_sweep_gradient_color4f(¢er, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, tileMode, startAngle, endAngle, null))); } }
public static SKImage FromTexture(GRRecordingContext 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(SkiaApi.sk_image_new_from_texture(context.Handle, texture.Handle, origin, colorType.ToNative(), alpha, cs, proxy, (void *)ctx))); }
public static SKShader CreateTwoPointConicalGradient(SKPoint start, float startRadius, SKPoint end, float endRadius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) { if (colors == null) throw new ArgumentNullException(nameof(colors)); }
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 SKSurface Create(GRContext context, GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (renderTarget == null) { throw new ArgumentNullException(nameof(renderTarget)); } return(GetObject(SkiaApi.sk_surface_new_backend_render_target(context.Handle, renderTarget.Handle, origin, colorType, colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero))); }
public static SKImage FromAdoptedTexture(GRRecordingContext 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(SkiaApi.sk_image_new_from_adopted_texture(context.Handle, texture.Handle, origin, colorType.ToNative(), alpha, cs))); }
public static SKSurface CreateAsRenderTarget(GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProperties props) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (texture == null) { throw new ArgumentNullException(nameof(texture)); } return(GetObject(SkiaApi.sk_surface_new_backend_texture_as_render_target(context.Handle, texture.Handle, origin, sampleCount, colorType, colorspace?.Handle ?? IntPtr.Zero, props?.Handle ?? IntPtr.Zero))); }
public SKImage ToTextureImage(GRContext context, SKColorSpace colorspace) => ToTextureImage(context, false);
public static SKShader CreateLinearGradient(SKPoint start, SKPoint end, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode) { if (colors == null) { throw new ArgumentNullException(nameof(colors)); } if (colorPos != null && colors.Length != colorPos.Length) { throw new ArgumentException("The number of colors must match the number of color positions."); } var points = stackalloc SKPoint[] { start, end }; fixed(SKColorF *c = colors) fixed(float *cp = colorPos) { return(GetObject(SkiaApi.sk_shader_new_linear_gradient_color4f(points, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, null))); } }
public SKPixmap WithColorSpace(SKColorSpace newColorSpace) { return(new SKPixmap(Info.WithColorSpace(newColorSpace), GetPixels(), RowBytes)); }
public static SKShader CreateRadialGradient(SKPoint center, float radius, SKColorF[] colors, SKColorSpace colorspace, float[] colorPos, SKShaderTileMode mode, SKMatrix localMatrix) { if (colors == null) { throw new ArgumentNullException(nameof(colors)); } if (colorPos != null && colors.Length != colorPos.Length) { throw new ArgumentException("The number of colors must match the number of color positions."); fixed(SKColorF *c = colors) fixed(float *cp = colorPos) { return(GetObject(SkiaApi.sk_shader_new_radial_gradient_color4f(¢er, radius, c, colorspace?.Handle ?? IntPtr.Zero, cp, colors.Length, mode, &localMatrix))); } }
public static SKSurface Create(GRRecordingContext context, CoreAnimation.CAMetalLayer layer, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, out CoreAnimation.ICAMetalDrawable drawable) => Create(context, layer, origin, sampleCount, colorType, colorspace, null, out drawable);