Hi,
I have created a xamarin cross-platform application to draw on an image and save the image with drawing using SkiaSharp.
Below code to draw an image in bitmap
//code to draw an image
if (!string.IsNullOrEmpty(ImageData))
{
string strimg64 = ImageData.Split(',')[1];
if (!string.IsNullOrEmpty(strimg64))
{
byte[] imageBytes = Convert.FromBase64String(strimg64);
Stream fileStream = new MemoryStream(imageBytes);
// clear the canvas / fill with white
bitmapCanvas.DrawColor(SKColors.White);
// decode the bitmap from the stream
using (var stream = new SKManagedStream(fileStream))
bitmap = SKBitmap.Decode(stream);
using (var paint = new SKPaint())
{
bitmapCanvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint);
}
}
}
And below code used to draw the image using finger move
foreach (SKPath path in completedPaths)
{
bitmapCanvas.DrawPath(path, paint);
}
foreach (SKPath path in inProgressPaths.Values)
{
bitmapCanvas.DrawPath(path, paint);
}
I can draw paint on the image but the problem is cant save the image with the drawing done. Only the image is saving in the gallery. I have attached the git link with the source. Please help to solve this problem to save the image with drawing.