delphiskiaskia4delphi

How to save a Skia4Delphi TSkPaintBox Canvas to file?


I am using the TSkPaintBox to capture a freehand signature the same as in the Skia demo app however I can find no way of getting a rasterised version of the canvas out into a TBitmap.


Solution

  • You can use the MakeScreenshot function from the FMX.Controls unit to take a screenshot of the component and then assign it to a TBitmap:

    var Bitmap := SkPaintBox1.MakeScreenshot;
    try
    
      // Save the Bitmap to file or do whatever you want with it
    
    finally
      Bitmap.Free;
    end;
    

    The MakeScreenshot function returns a TBitmap. Just remember to free it when you're done using it.