lazarus-ccr/components/skia/demo/console/ConsoleAppSkiaFPC.lpr
mgaertner efda057bcc added skia
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9338 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2024-04-24 14:12:06 +00:00

42 lines
907 B
ObjectPascal

{
Demo for a console app using the libsk4d library to create a surface, draw
on the canvas, and save the result as png file.
Note: In skia4delphi 6.1 when the library is not found it silently aborts.
}
program ConsoleAppSkiaFPC;
{$IFDEF MSWindows}
{$APPTYPE CONSOLE}
{$ENDIF}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
dynlibs { dynlibs is needed when loading dynamic lib libsk4d },
SysUtils, System.UITypes,
System.Skia;
procedure TestSkSurface;
var
LSurface: ISkSurface;
begin
// Creating a solid red image using SkSurface
LSurface := TSkSurface.MakeRaster(200, 200);
LSurface.Canvas.Clear(TAlphaColors.Red); // $FFFF0000
// create png file
LSurface.MakeImageSnapshot.EncodeToFile('test.png');
end;
begin
try
TestSkSurface;
WriteLn('Created test.png, <Enter>');
ReadLn;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.