private static IntPtr CreateNewInternal(IntPtr managedStreamPtr) { var managedStream = AsManagedStream(managedStreamPtr); var newStream = new SKManagedStream(managedStream.stream, false, false); return(newStream.Handle); }
public static void BitmapShaderManipulated(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode(stream)) { // invert the pixels var pixels = source.Pixels; for (int i = 0; i < pixels.Length; i++) { pixels[i] = new SKColor( (byte)(255 - pixels [i].Red), (byte)(255 - pixels [i].Green), (byte)(255 - pixels [i].Blue), pixels [i].Alpha); } source.Pixels = pixels; using (var shader = SKShader.CreateBitmap(source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat)) using (var paint = new SKPaint()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear(SKColors.White); canvas.DrawPaint(paint); } } }
public static void BitmapShader(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode(stream)) { // create the shader and paint //SkMatrix matrix; //matrix.setScale(0.75f, 0.75f); //matrix.preRotate(30.0f); var matrix = SKMatrix.MakeRotation(30.0f); using (var shader = SKShader.CreateBitmap(source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat, matrix)) using (var paint = new SKPaint()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear(SKColors.White); canvas.DrawPaint(paint); } } }
public static void ColorTableColorFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; var ct = new byte[256]; for (int i = 0; i < 256; ++i) { var x = (i - 96) * 255 / 64; ct[i] = x < 0 ? (byte)0 : x > 255 ? (byte)255 : (byte)x; } // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) using (var cf = SKColorFilter.CreateTable(null, ct, ct, ct)) using (var paint = new SKPaint()) { paint.ColorFilter = cf; canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); } }
private static bool AsManagedStream(IntPtr ptr, out SKManagedStream target) { if (managedStreams.TryGetValue(ptr, out target)) { return(true); } target = null; return(false); }
public static SKData Create(Stream stream, long length) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using (var managed = new SKManagedStream(stream)) return(Create(managed, length)); }
public static SKPicture Deserialize(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using var managed = new SKManagedStream(stream); return(Deserialize(managed)); }
protected override IntPtr OnFork() { VerifyOriginal(); var newStream = new SKManagedStream(stream, disposeStream); wasCopied = true; disposeStream = false; return(newStream.Handle); }
public static void CustomFonts(SKCanvas canvas, int width, int height) { string text = "\u03A3 and \u0750"; using (var paint = new SKPaint()) { canvas.Clear(SKColors.White); paint.IsAntialias = true; using (var tf = SKTypeface.FromFile(CustomFontPath)) { paint.Color = XamGreen; paint.TextSize = 60; paint.Typeface = tf; canvas.DrawText(text, 50, 50, paint); } using (var stream = new SKFileStream(CustomFontPath)) using (var tf = SKTypeface.FromStream(stream)) { paint.Color = XamDkBlue; paint.TextSize = 60; paint.Typeface = tf; canvas.DrawText(text, 50, 100, paint); } var assembly = typeof(Demos).GetTypeInfo().Assembly; var fontName = assembly.GetName().Name + ".embedded-font.ttf"; using (var resource = assembly.GetManifestResourceStream(fontName)) using (var memory = new MemoryStream()) { resource.CopyTo(memory); var bytes = memory.ToArray(); using (var stream = new SKMemoryStream(bytes)) using (var tf = SKTypeface.FromStream(stream)) { paint.Color = XamLtBlue; paint.TextSize = 60; paint.Typeface = tf; canvas.DrawText(text, 50, 150, paint); } } using (var resource = assembly.GetManifestResourceStream(fontName)) using (var stream = new SKManagedStream(resource)) using (var tf = SKTypeface.FromStream(stream)) { paint.Color = XamPurple; paint.TextSize = 60; paint.Typeface = tf; canvas.DrawText(text, 50, 200, paint); } } }
private static bool AsManagedStream(IntPtr ptr, out SKManagedStream target) { WeakReference <SKManagedStream> weak; if (managedStreams.TryGetValue(ptr, out weak)) { if (weak.TryGetTarget(out target)) { return(true); } } target = null; return(false); }
public static void BitmapDecoder(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; canvas.Clear(SKColors.White); // load the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var decoder = new SKImageDecoder(stream)) using (var paint = new SKPaint()) using (var tf = SKTypeface.FromFamilyName("Arial")) { paint.IsAntialias = true; paint.TextSize = 14; paint.Typeface = tf; paint.Color = SKColors.Black; // read / set decoder settings decoder.DitherImage = true; decoder.PreferQualityOverSpeed = true; decoder.SampleSize = 2; // decode the image using (var bitmap = new SKBitmap()) { var result = decoder.Decode(stream, bitmap); if (result != SKImageDecoderResult.Failure) { var info = bitmap.Info; var x = 25; var y = 25; canvas.DrawBitmap(bitmap, x, y); x += info.Width + 25; y += 14; canvas.DrawText(string.Format("Result: {0}", result), x, y, paint); y += 20; canvas.DrawText(string.Format("Size: {0}px x {1}px", bitmap.Width, bitmap.Height), x, y, paint); y += 20; canvas.DrawText(string.Format("Pixels: {0} @ {1}b/px", bitmap.Pixels.Length, bitmap.BytesPerPixel), x, y, paint); } } } }
public IBitmapImpl LoadBitmap(System.IO.Stream stream) { using (var s = new SKManagedStream(stream)) { var bitmap = SKBitmap.Decode(s); if (bitmap != null) { return new BitmapImpl(bitmap); } else { throw new ArgumentException("Unable to load bitmap from provided data"); } } }
public static SKData Create(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (stream.CanSeek) { return(Create(stream, stream.Length)); } else { using var memory = new SKDynamicMemoryWStream(); using (var managed = new SKManagedStream(stream)) { managed.CopyTo(memory); } return(memory.DetachAsData()); } }
public static void BlurImageFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) using (var filter = SKImageFilter.CreateBlur(5, 5)) using (var paint = new SKPaint()) { paint.ImageFilter = filter; canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); } }
protected override IntPtr OnDuplicate() { VerifyOriginal(); if (!stream.CanSeek) { return(IntPtr.Zero); } var newStream = new SKManagedStream(stream, disposeStream); newStream.parent = new WeakReference(this); wasCopied = true; disposeStream = false; child = new WeakReference(newStream); stream.Position = 0; return(newStream.Handle); }
public IBitmapImpl LoadBitmap(System.IO.Stream stream) { using (var s = new SKManagedStream(stream)) { using (var codec = SKCodec.Create(s)) { var info = codec.Info; var bitmap = new SKBitmap(info.Width, info.Height, SKImageInfo.PlatformColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul); IntPtr length; var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length)); if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput) { return new BitmapImpl(bitmap); } else { throw new ArgumentException("Unable to load bitmap from provided data"); } } } }
public static void ColorMatrixColorFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) { var f = new Action <SKRect, float[]>((rect, colorMatrix) => { using (var cf = SKColorFilter.CreateColorMatrix(colorMatrix)) using (var paint = new SKPaint()) { paint.ColorFilter = cf; canvas.DrawBitmap(bitmap, rect, paint); } }); var colorMatrix1 = new float[20] { 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var grayscale = new float[20] { 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var colorMatrix3 = new float[20] { -1f, 1f, 1f, 0f, 0f, 1f, -1f, 1f, 0f, 0f, 1f, 1f, -1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var colorMatrix4 = new float[20] { 0.0f, 0.5f, 0.5f, 0f, 0f, 0.5f, 0.0f, 0.5f, 0f, 0f, 0.5f, 0.5f, 0.0f, 0f, 0f, 0.0f, 0.0f, 0.0f, 1f, 0f }; var highContrast = new float[20] { 4.0f, 0.0f, 0.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 4.0f, 0.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 0.0f, 4.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var colorMatrix6 = new float[20] { 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var sepia = new float[20] { 0.393f, 0.769f, 0.189f, 0.0f, 0.0f, 0.349f, 0.686f, 0.168f, 0.0f, 0.0f, 0.272f, 0.534f, 0.131f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var inverter = new float[20] { -1f, 0f, 0f, 0f, 255f, 0f, -1f, 0f, 0f, 255f, 0f, 0f, -1f, 0f, 255f, 0f, 0f, 0f, 1f, 0f }; var matices = new[] { colorMatrix1, grayscale, highContrast, sepia, colorMatrix3, colorMatrix4, colorMatrix6, inverter }; var cols = width < height ? 2 : 4; var rows = (matices.Length - 1) / cols + 1; var w = (float)width / cols; var h = (float)height / rows; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { f(SKRect.Create(x * w, y * h, w, h), matices[y * cols + x]); } } } }
public static void BitmapShader (SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo ().Assembly; var imageName = assembly.GetName ().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream (imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode (stream)) { // create the shader and paint //SkMatrix matrix; //matrix.setScale(0.75f, 0.75f); //matrix.preRotate(30.0f); var matrix = SKMatrix.MakeRotation (30.0f); using (var shader = SKShader.CreateBitmap (source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat, matrix)) using (var paint = new SKPaint ()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear (SKColors.White); canvas.DrawPaint (paint); } } }
public static void BitmapShaderManipulated (SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo ().Assembly; var imageName = assembly.GetName ().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream (imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode (stream)) { // invert the pixels var pixels = source.Pixels; for (int i = 0; i < pixels.Length; i++) { pixels[i] = new SKColor ( (byte)(255 - pixels [i].Red), (byte)(255 - pixels [i].Green), (byte)(255 - pixels [i].Blue), pixels [i].Alpha); } source.Pixels = pixels; using (var shader = SKShader.CreateBitmap (source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat)) using (var paint = new SKPaint ()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear (SKColors.White); canvas.DrawPaint (paint); } } }
public static void ColorMatrixColorFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) { var f = new Action<SKRect, float[]>((rect, colorMatrix) => { using (var cf = SKColorFilter.CreateColorMatrix(colorMatrix)) using (var paint = new SKPaint()) { paint.ColorFilter = cf; canvas.DrawBitmap(bitmap, rect, paint); } }); var colorMatrix1 = new float[20] { 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var grayscale = new float[20] { 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.21f, 0.72f, 0.07f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var colorMatrix3 = new float[20] { -1f, 1f, 1f, 0f, 0f, 1f, -1f, 1f, 0f, 0f, 1f, 1f, -1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var colorMatrix4 = new float[20] { 0.0f, 0.5f, 0.5f, 0f, 0f, 0.5f, 0.0f, 0.5f, 0f, 0f, 0.5f, 0.5f, 0.0f, 0f, 0f, 0.0f, 0.0f, 0.0f, 1f, 0f }; var highContrast = new float[20] { 4.0f, 0.0f, 0.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 4.0f, 0.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 0.0f, 4.0f, 0.0f, -4.0f * 255f / (4.0f - 1f), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var colorMatrix6 = new float[20] { 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 1f, 0f }; var sepia = new float[20] { 0.393f, 0.769f, 0.189f, 0.0f, 0.0f, 0.349f, 0.686f, 0.168f, 0.0f, 0.0f, 0.272f, 0.534f, 0.131f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; var inverter = new float[20] { -1f, 0f, 0f, 0f, 255f, 0f, -1f, 0f, 0f, 255f, 0f, 0f, -1f, 0f, 255f, 0f, 0f, 0f, 1f, 0f }; var matices = new[] { colorMatrix1, grayscale, highContrast, sepia, colorMatrix3, colorMatrix4, colorMatrix6, inverter }; var cols = width < height ? 2 : 4; var rows = (matices.Length - 1) / cols + 1; var w = (float)width / cols; var h = (float)height / rows; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { f(SKRect.Create(x * w, y * h, w, h), matices[y * cols + x]); } } } }
private static bool AsManagedStream(IntPtr ptr, out SKManagedStream target) { WeakReference<SKManagedStream> weak; lock (managedStreams){ if (managedStreams.TryGetValue (ptr, out weak)) { if (weak.TryGetTarget(out target)) { return true; } } } target = null; return false; }
public static void BitmapDecoder(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; canvas.Clear(SKColors.White); // load the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var codec = SKCodec.Create(stream)) using (var paint = new SKPaint()) using (var tf = SKTypeface.FromFamilyName("Arial")) { var info = codec.Info; paint.IsAntialias = true; paint.TextSize = 14; paint.Typeface = tf; paint.Color = SKColors.Black; // decode the image using (var bitmap = new SKBitmap(info.Width, info.Height, info.ColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul)) { IntPtr length; var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length)); if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput) { var x = 25; var y = 25; canvas.DrawBitmap(bitmap, x, y); x += bitmap.Info.Width + 25; y += 14; canvas.DrawText(string.Format("Result: {0}", result), x, y, paint); y += 20; canvas.DrawText(string.Format("Size: {0}px x {1}px", bitmap.Width, bitmap.Height), x, y, paint); y += 20; canvas.DrawText(string.Format("Pixels: {0} @ {1}b/px", bitmap.Pixels.Length, bitmap.BytesPerPixel), x, y, paint); } } } }
public static void ChainedImageFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; var size = width > height ? height : width; var small = size / 5; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) using (var filterMag = SKImageFilter.CreateMagnifier(SKRect.Create(small*2, small*2, small*3, small*3), small)) using (var filterBlur = SKImageFilter.CreateBlur(5, 5, filterMag)) using (var paint = new SKPaint()) { paint.ImageFilter = filterBlur; canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); } }
public static void BitmapLattice (SKCanvas canvas, int width, int height) { canvas.Clear (SKColors.White); var assembly = typeof (Demos).GetTypeInfo ().Assembly; var imageName = assembly.GetName ().Name + ".nine-patch.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream (imageName)) using (var stream = new SKManagedStream (resource)) using (var bitmap = SKBitmap.Decode (stream)) { var patchCenter = new SKRectI (33, 33, 256 - 33, 256 - 33); // 2x3 for portrait, or 3x2 for landscape var land = width > height; var min = land ? Math.Min (width / 3f, height / 2f) : Math.Min (width / 2f, height / 3f); var wide = SKRect.Inflate (SKRect.Create (0, land ? min : (min * 2f), min * 2f, min), -6, -6); var tall = SKRect.Inflate (SKRect.Create (land ? (min * 2f) : min, 0, min, min * 2f), -6, -6); var square = SKRect.Inflate (SKRect.Create (0, 0, min, min), -6, -6); var text = SKRect.Create (land ? min : 0, land ? 0 : min, min, min / 5f); text.Offset (text.Width / 2f, text.Height * 1.5f); text.Right = text.Left; // draw the bitmaps canvas.DrawBitmapNinePatch (bitmap, patchCenter, square); canvas.DrawBitmapNinePatch (bitmap, patchCenter, tall); canvas.DrawBitmapNinePatch (bitmap, patchCenter, wide); // describe what we see using (var paint = new SKPaint ()) { paint.TextAlign = SKTextAlign.Center; paint.TextSize = text.Height * 0.75f; canvas.DrawText ("The corners", text.Left, text.Top, paint); text.Offset (0, text.Height); canvas.DrawText ("should always", text.Left, text.Top, paint); text.Offset (0, text.Height); canvas.DrawText ("be square", text.Left, text.Top, paint); } } }
public static SKBitmapInfo LoadTexture(Stream bitmapStream) { bitmapStream.Position = 0; var stream = new SKManagedStream(bitmapStream); return new SKBitmapInfo {Bitmap = SKBitmap.Decode(stream)}; }
public static void CustomFonts (SKCanvas canvas, int width, int height) { string text = "\u03A3 and \u0750"; using (var paint = new SKPaint ()) { canvas.Clear (SKColors.White); paint.IsAntialias = true; using (var tf = SKTypeface.FromFile (CustomFontPath)) { paint.Color = XamGreen; paint.TextSize = 40; paint.Typeface = tf; canvas.DrawText (text, 50, 50, paint); } using (var stream = new SKFileStream (CustomFontPath)) using (var tf = SKTypeface.FromStream (stream)) { paint.Color = XamDkBlue; paint.TextSize = 40; paint.Typeface = tf; canvas.DrawText (text, 50, 100, paint); } var assembly = typeof(Demos).GetTypeInfo ().Assembly; var fontName = assembly.GetName ().Name + ".embedded-font.ttf"; using (var resource = assembly.GetManifestResourceStream (fontName)) using (var memory = new MemoryStream ()) { resource.CopyTo (memory); var bytes = memory.ToArray (); using (var stream = new SKMemoryStream (bytes)) using (var tf = SKTypeface.FromStream (stream)) { paint.Color = XamLtBlue; paint.TextSize = 40; paint.Typeface = tf; canvas.DrawText (text, 50, 150, paint); } } using (var resource = assembly.GetManifestResourceStream (fontName)) using (var stream = new SKManagedStream (resource)) using (var tf = SKTypeface.FromStream (stream)) { paint.Color = XamPurple; paint.TextSize = 40; paint.Typeface = tf; canvas.DrawText (text, 50, 200, paint); } } }
public static void DilateImageFilter(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".baboon.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var bitmap = SKBitmap.Decode(stream)) using (var filter = SKImageFilter.CreateDilate(5, 5)) using (var paint = new SKPaint()) { paint.ImageFilter = filter; canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); } }
protected override IntPtr OnCreateNew() { var newStream = new SKManagedStream(stream, false, false); return(newStream.Handle); }
private static IntPtr CreateNewInternal (IntPtr managedStreamPtr) { var managedStream = AsManagedStream (managedStreamPtr); var newStream = new SKManagedStream (managedStream.stream, false, false); managedStream.TakeOwnership (newStream); return newStream.Handle; }