I am trying to adapt the aa-demo program of the BGRA library to my own use. I've included the small project I've been working with, but here's the highlight:
1. I've declared the following form:
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label_PixelSizeValue: TLabel;
Panel1: TPanel;
SpinEdit_Gamma: TFloatSpinEdit;
TrackBar_PixelSize: TTrackBar;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
fpts: array[1..4] of TPointF;
fPixelSize : Integer;
fMovingPointIndex : integer;
function coordToBmp(pt: TPointF): TPointF;
public
end;
The relevant methods are as follows:
function TForm1.coordToBmp(pt: TPointF): TPointF;
begin
result := (pt+PointF(0.5,0.5))*(1/fpixelSize)-PointF(0.5,0.5);
end;
and
procedure TForm1.FormCreate(Sender: TObject);
begin
//Let's try and draw a rectangle.
fpts[1] := PointF(100,100);
fpts[2] := PointF(200,100);
fpts[3] := PointF(200,10 );
fpts[4] := PointF(10 , 10);
Label_PixelSizeValue.Caption := '= ' + IntToStr(TrackBar_PixelSize.Position);
fMovingPointIndex := -1;
SpinEdit_Gamma.Value := BGRAGetGamma;
end;
Finally:
procedure TForm1.FormPaint(Sender: TObject);
var bmp : TBGRABitmap;
aZoomX ,
aZoomY : Integer ;
tx, ty : Integer ;
begin
aZoomX := ClientWidth;
aZoomY := Panel1.Top ;
fPixelSize := TrackBar_PixelSize.Position;
tx := (aZoomX + fPixelSize - 1) div fPixelSize;
ty := (aZoomY + fPixelSize - 1) div fPixelSize;
//Draw Square
bmp := TBGRABitmap.Create(tx,ty,BGRAWhite);
bmp.RectangleAntialias({x =} 10, {y = } 10, {x2 =} 100, {y2 = } 100, {c = } BGRABlack, {w = } 5, {back =} BGRAWhite);
bmp.FillPolyAntialias([CoordToBMP(fpts[1]), coordToBMP(fpts[2]), coordToBMP(fpts[3]), coordToBMP(fpts[4])], BGRABlack);
bmp.Free;
end;
When I run the code, nothing gets painted on the form. What am I doing wrong?
Thanks for any tip and suggestions!