Questions tagged [skiasharp]

SkiaSharp provides a cross-platform C# API for doing 2D graphics. It is powered by Google’s Skia library, the same library that powers Google Chrome, Firefox and Android’s graphic stacks.

SkiaSharp provides a cross-platform C# API for doing 2D graphics. It is powered by Google’s Skia library, the same library that powers Google Chrome, Firefox and Android’s graphic stacks.

Features include:

  • 3x3 matrices w/ perspective
  • antialiasing, transparency, filters
  • shaders, xfermodes, maskfilters, patheffects
  • subpixel text

Device backends for SkiaSharp currently include:

  • Raster
  • OpenGL / DirectX
  • PDF
  • Picture (for recording and then playing back into another Canvas)

Supported Platforms:

  • Windows (Classic Desktop / WPF / UWP)
  • Xamarin.Android
  • Xamarin.iOS
  • Xamarin.Mac
  • Xamarin.tvOS

SkiaSharp can also be used in PCLs (Portable Class Libraries) to have 100% shared code. These PCLs can then be used with Xamarin.Forms, MVVMCross or any other shared application framework.

More information available at:

  1. github.com/mono/skiasharp
  2. learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp
462 questions
11
votes
2 answers

Rotate photo with SkiaSharp

I'm trying to rotate photo with SkiaSharp to 90 degrees with following code: public SKBitmap Rotate() { var bitmap = SKBitmap.Decode("test.jpg"); using (var surface = new SKCanvas(bitmap)) { …
Dmitry
  • 123
  • 1
  • 6
11
votes
1 answer

How to add rect using Skia Sharp and apply both fill color and stroke color to that object?

How to add rect or any shape using Skia Sharp and apply both fill color and stroke color to that object in iOS
Devaraj
  • 138
  • 1
  • 8
10
votes
3 answers

Using SkiaSharp.SKBitmap image as the ImageSource for a Button in Xamarin

I am attempting to use/convert the SKBitmap image as/to an ImageSource object in order to use the aforementioned image in a Button by assignment to its ImageSource property but, for the life of me, cannot figure out how to convert an SKBitmap object…
hecate
  • 620
  • 1
  • 8
  • 33
9
votes
1 answer

C# SkiaSharp OpenTK Winform - How to draw from a background thread?

I am trying to replace GDI+ with SkiaSharp for a data visualization framework that renders multi-layered pannable-zoomable graphs with real-time continuously changing engineering data. In GDI+, the application did this: Created a collection of…
user1689175
  • 767
  • 10
  • 18
9
votes
2 answers

DllNotFoundException using SkiaSharp 1.68 on Linux

Using SkiaSharp 1.68.0 with .NET Core 2.2 on Linux and get this error when trying to use Decode on a jpeg-memory-stream (same code works on Windows): System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream'…
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
8
votes
2 answers

Skiasharp Export canvas to image

I have a question. I have a skiasharp canvas with a few bitmaps. Now I want to export the canvas with the bitmaps to an Image, but I have no idea how to do that, or if that is possible. Can someone help me?
user12520502
8
votes
1 answer

Multiple clipping regions on a PDF page not working

I'm using SkiaSharp to print labels to PDF (and other things). Each page of the PDF can have multiple rows and columns. I need to clip each label to the correct size so it's doesn't trash neighbouring labels. For testing, each label has a…
Jonesie
  • 6,997
  • 10
  • 48
  • 66
8
votes
1 answer

Passing the current platform font into SKTypeface?

When attempting to render Chinese (or other symbolic) text. SkiSharp will render boxes instead of the correct Chinese characters. Obviously the font that Skia is using by default doesn't support those characters. So we have to assign our own…
Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
8
votes
0 answers

How to use double buffering with SkiaSharp

I'm just playing around with Xamarin Forms and SkiaSharp. I've create a simple Xamarin forms ContentView with a SkiaCanvas. My PaintSurface is as follows to draw a simple green circle: private void canvas_PaintSurface(object sender,…
8
votes
1 answer

How to colorize black and white SVG loaded with SkiaSharp?

I'm playing with new release of SkiaSharp (1.55) that support loading SVG on Xamarin.Android (and not only). Due to the fact that it was release less than 10 days ago I couldn't find so much documentation. After loading an SVG in black and white,…
Daniele D.
  • 2,624
  • 3
  • 36
  • 42
7
votes
1 answer

Using C# to measure the width of a string in pixels in a cross platform way

I have some existing C# code that uses System.Drawing.Common to measure the approximate width of a string in pixels: var text = "abc123 this is some long text my dog's name is fido."; using (var bitmap = new Bitmap(500, 50)) using (var graphics =…
Jon Sagara
  • 1,122
  • 2
  • 11
  • 16
7
votes
0 answers

How can I render a set of primitives using Avalonia and Skia backend on macos?

I need to create a simple app to draw a graph network onto a canvas. As I use .net core it seems that one of the best solutions could be Avalonia + Skia backend. The problem is that I haven't found any good documentation or example showing it. How…
Notbad
  • 5,936
  • 12
  • 54
  • 100
7
votes
2 answers

How to compile skia on Windows

I tried compiling skia on Windows as suggested in https://skia.org/user/build bin/gn gen out/Static --args='is_official_build=true' ninja -C out/Static Build fails to find libjpeg.h, libpng.h Then I added following line in gn args extra_cflags =…
david
  • 321
  • 3
  • 12
7
votes
1 answer

SKGLView much darker than SKCanvasView

My app's main screen is rendered via SKCanvasView. The colors accurately reflect the values I specified in code. If I swap-in SKGLView (hardware-accelerated version), changing no other code, the result is 60% darker: