Hello,
You can install Microsoft.Maui.Graphics.Skia
in the nuget package manager, then use SkiaBitmapExportContext to create a bitmap in memory and draw on its Canvas
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Graphics.Skia;
SkiaBitmapExportContext skiaBitmapExportContext= new(width, height, displayScale);
ICanvas canvas = skiaBitmapExportContext.Canvas;
After drawing, you can save image as png file with WriteToFile method, I save this image at FileSystem.Current.AppDataDirectory path.
string mainDir = FileSystem.Current.AppDataDirectory;
string filePath = Path.Combine(mainDir, "MyTest.png");
// Save the image as a PNG file
skiaBitmapExportContext.WriteToFile(filePath);
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.