Bonjour !

Je voulais essayer d'utiliser BGRABitmap sans Lazarus, dans une application console (pour fabriquer une image PNG et la sauvegarder dans un fichier).

Tant qu'il n'y a pas de texte, ça marche. Mais lorsqu'il y a du texte, l'application se compile mais lorque la fenêtre noire s'ouvre rien ne se passe (aucun fichier n'est créé) et l'application est bloquée : je dois la fermer manuellement, alors qu'elle devrait se fermer toute seule.

Voici un exemple de programme avec lequel j'ai rencontré le problème :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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.
Je précise que j'ai bien un fichier arial.ttf dans le même dossier que le programme.

Et voici le fichier de commande dont je me sers :

Code Batch : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
set path=C:\FPC\3.0.2\bin\i386-win32
 
if not exist units md units
 
set bgra=C:\Sources\bgrabitmap\bgrabitmap
set lazutils=C:\Sources\lazutils
 
fpc.exe -Mobjfpc -dBGRABITMAP_DONT_USE_LCL -Fu%lazutils% -Fu%bgra% -FUunits %1

Auriez-vous une idée de ce qui ne va pas ?