Yes I used -o2 optimisations and -oR.
Here is the current test code.
procedure TForm1.Button3Click(Sender: TObject);
var ix,iy:integer;
tbm:tbitmap;
startms,finishms:int64;
{$IFDEF FPC}
bmp:TBGRABitmap;
{$ENDIF}
begin
startms:=gettickcount;
tbm:=tbitmap.create;
tbm.width:=image1.width;
tbm.height:=image1.height;
{$IFDEF FPC}
bmp:=TBGRABitmap.Create(tbm.width,tbm.height,BGRABlack);
{$ENDIF}
for iy:=0 to image1.height-1 do
begin
for ix:=0 to image1.width-1 do
begin
{$IFDEF FPC}
bmp.setpixel(ix,iy,rgb(0,255,0));
{$ELSE}
tbm.canvas.pixels[ix,iy]:=rgb(0,255,0);
{$ENDIF}
end;
if iy mod 5=0 then
begin
{$IFDEF FPC}
bmp.InvalidateBitmap;
bmp.Draw(tbm.canvas,0,0,True);
image1.canvas.draw(0,0,tbm);
//bmp.Draw(image1.canvas,0,0,True);
{$ELSE}
image1.canvas.draw(0,0,tbm);
{$ENDIF}
application.processmessages;
end;
end;
{$IFDEF FPC}
bmp.InvalidateBitmap;
bmp.Draw(tbm.canvas,0,0,True);
image1.canvas.draw(0,0,tbm);
//bmp.Draw(image1.canvas,0,0,True);
{$ELSE}
image1.canvas.draw(0,0,tbm);
{$ENDIF}
application.processmessages;
finishms:=gettickcount;
{$IFDEF FPC}
bmp.free;
{$ENDIF}
showmessage('time taken = '+inttostr(finishms-startms)+' ms');
end;
That does it in 624ms compared to Delphi scanline 203ms. So it seems your BGRA is fast enough. By the way, is using setpixel the best option? I do want the code to be cross platform in the future.