1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| program test;
uses
Classes, SysUtils,
BGRAGraphics, BGRABitmap, BGRABitmapTypes;
procedure DrawEllipseHello(aBitmap: TBGRABitmap);
begin
aBitmap.Fill(BGRABlack);
aBitmap.CustomPenStyle := BGRAPenStyle(2, 1);
aBitmap.FillEllipseLinearColorAntialias(aBitmap.Width / 2, aBitmap.Height / 2, aBitmap.Width / 2 - 5, aBitmap.Height / 2 - 5, BGRAPixelTransparent, BGRAWhite);
aBitmap.EllipseAntialias(aBitmap.Width / 2, aBitmap.Height / 2, aBitmap.Width / 2 - 5, aBitmap.Height / 2 - 5, CSSRed, 5);
if aBitmap.Height div 10 < 10 then
aBitmap.FontHeight := 10
else
aBitmap.FontHeight := aBitmap.Height div 10;
with aBitmap.FontPixelMetric do
aBitmap.TextOut(aBitmap.Width / 2, aBitmap.Height / 2 - (CapLine + Baseline) / 2, 'Hello world', BGRABlack, taCenter);
aBitmap.Canvas.Pen.Color := clBlue;
aBitmap.Canvas.MoveTo(0, 0);
aBitmap.Canvas.LineTo(aBitmap.Width, aBitmap.Height);
end;
var
bmp: TBGRABitmap;
begin
TBGRABitmap.AddFreeTypeFontFolder(GetCurrentDir);
bmp := TBGRABitmap.Create(800, 600, BGRABlack);
DrawEllipseHello(bmp);
bmp.SaveToFile('test.png');
bmp.Free;
end. |
Partager