1 unit Unit1; 2 3 {$mode objfpc}{$H+} 4 5 interface 6 7 uses 8 Classes, SysUtils, LCLProc, FileUtil, LazFileUtils, LResources, Forms, 9 Controls, Graphics, Dialogs, FPimage, agg_fpimage, Agg_LCL; 10 11 type 12 13 { TForm1 } 14 15 TForm1 = class(TForm) 16 procedure FormCreate(Sender: TObject); 17 procedure FormDestroy(Sender: TObject); 18 procedure FormPaint(Sender: TObject); 19 private 20 public 21 AggLCLCanvas: TAggLCLCanvas; 22 Bitmap1: TBitmap; 23 end; 24 25 var 26 Form1: TForm1; 27 28 implementation 29 30 { TForm1 } 31 32 procedure TForm1.FormCreate(Sender: TObject); 33 var 34 FontFilename: String; 35 begin 36 Bitmap1:=TBitmap.Create; 37 AggLCLCanvas:=TAggLCLCanvas.Create; 38 with AggLCLCanvas do begin 39 Image.PixelFormat:=afpimRGBA32; 40 Image.SetSize(250,250); 41 end; 42 43 // paint to agg canvas 44 with AggLCLCanvas do begin 45 // solid white background 46 Brush.Color:=clWhite; 47 FillRect(0,0,Width,Height); 48 49 // a star with 5 corners, solid blue outline, filled solid yellow 50 Brush.Color:=clYellow; 51 Pen.Color:=clBlue; 52 Pen.Width:=8; 53 Ellipse(20,50,100,100); 54 55 // a star with 5 corners, transparent blue outline, filled transparent yellow 56 Brush.FPColor:=FPColor($ffff,$ffff,0,$5000); 57 Pen.FPColor:=FPColor(0,0,$ffff,$5000); 58 Ellipse(40,65,120,130); 59 60 // solid blue text 61 FontFilename:=SetDirSeparators('../../verdana.ttf'); 62 DebugLn(['TForm1.FormCreate ',FontFilename,' ',FileExistsUTF8(FontFilename)]); 63 Font.LoadFromFile(FontFilename); 64 Font.Size:=18; 65 Font.Color:=clRed; 66 TextOut(10,30,'LCL and AggPas'); 67 end; 68 69 // convert to LCL native pixel format 70 Bitmap1.LoadFromIntfImage(AggLCLCanvas.Image.IntfImg); 71 end; 72 73 procedure TForm1.FormDestroy(Sender: TObject); 74 begin 75 AggLCLCanvas.Free; 76 Bitmap1.Free; 77 end; 78 79 procedure TForm1.FormPaint(Sender: TObject); 80 begin 81 Canvas.Draw(0,0,Bitmap1); 82 end; 83 84 {$R *.lfm} 85 86 end. 87 88