I am trying to paint on bitmap image and then updated drawing needs to be saved
till now I was able to get the image on canvas and also I am able to draw on bitmap image but the problem is when I export the stream I could not see my drawing I only get the bitmap stream
Here is the code which I implemented till now
Global Variable
private SKBitmap sKBitmap;
Contructor
using (Stream stream = ImageDataStream)
{
sKBitmap = SKBitmap.Decode(stream);
}
InvalidatedSurface
private void OnCanvasViewPaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
{
globalSurface = args.Surface;
SKCanvas canvas = globalSurface.Canvas;
SKImageInfo info = args.Info;
canvas.Clear();
if (sKBitmap != null)
{
canvas.DrawBitmap(sKBitmap, info.Rect, BitmapStretch.Uniform);
}
foreach (SKPath path in completedPaths)
{
canvas.DrawPath(path, paint);
}
foreach (SKPath path in inProgressPaths.Values)
{
canvas.DrawPath(path, paint);
}
}
Canvas Saving Code
using (SKImage image = SKImage.FromBitmap(sKBitmap))
{
SKData data = image.Encode();
var imageBytes = data.ToArray();
}
while saving I get the original image rather than updated one with drawing not sure what wrong I am doing with this