How to convert a SKBitmap at the screen, to a System.IO.Stream ?
You can convert a SKBitmap into a Stream via an SKImage:
// get the bitmap we want to convert to a stream
SKBitmap bitmap = ...;
// create an image COPY
SKImage image = SKImage.FromBitmap(bitmap);
// create an image WRAPPER
SKImage image = SKImage.FromPixels(bitmap.PeekPixels());
// encode the image (defaults to PNG)
SKData encoded = image.Encode();
// get a stream over the encoded data
Stream stream = encoded.AsStream();
Is this what you are looking for?
Yes, thx, and what about to convert SKCanvasView to stream ?
SKCanvasView is not really anything more that a view that just displays an canvas (created for you in the paint cycle`.
To capture the drawn bitmap, you can get an image at the end of the paint method via the surface:
SKSurface surface = e.Surface;
SKImage image = e.Surface.Snapshot();
@mattleibow does Skia support saving the SKBitmap with a specified dpi resolution? I see that a after creating a SKBitmap and saving it to png, it is set to 96 dpi. I need to create higher resolution images when saving the SKBitmap... any hint on this topic? thanks in advance
@mattleibow does Skia support saving the SKBitmap with a specified dpi resolution? I see that a after creating a SKBitmap and saving it to png, it is set to 96 dpi. I need to create higher resolution images when saving it. Is it possible?
@GMGM, I replied to your other post: https://forums.xamarin.com/discussion/102644/skbitmap-and-dpi
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies