Code: Alles auswählen
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, LCLType, IntfGraphics, fpImage, opbitmap, lclintf{GetTickCount};
type
//TRGBTripleArray = array[0..32767] of TRGBTriple;
//PRGBTripleArray = ^TRGBTripleArray;
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
const w = 2000;
const h = 2000;
const l = 10;
var
SrcIntfImg: TLazIntfImage;
T2: TBitmap;
OP: TCanvasOPBitmap;
px, py, i: integer;
s, e: Cardinal;
Row: PRGBTripleArray;
Line:PAPixel32;
begin
//OpBitmap
OP := TCanvasOPBitmap.Create;
OP.Width := w;
OP.Height := h;
s := GetTickCount;
for i:=0 to l do
for py := 0 to h - 1 do
for px := 0 to w - 1 do Op.Canvas.Pixels[px, py] := clred;
e := GetTickCount - s;
Edit1.Text:=InttoStr(e);
OP.free;
//OpBitmap mit Scanline
OP := TCanvasOPBitmap.Create;
OP.Width := w;
OP.Height := h;
OP.PixelFormat:=pf32bit;
s := GetTickCount;
for i:=0 to l do
for py := 0 to h - 1 do
begin
Line:=Op.ScanLine[pY];
for px := 0 to w - 1 do
begin
Line^[px].Red:=255;
Line^[px].Blue:=0;
Line^[px].Green:=0;
end;
end;
e := GetTickCount - s;
Edit2.Text:=InttoStr(e);
//LazIntfImg
SrcIntfImg := TLazIntfImage.Create(0, 0);
SrcIntfImg.DataDescription := GetDescriptionFromDevice(0);
SrcIntfImg.SetSize(w, h);
s := GetTickCount;
for i:=0 to l do
for py := 0 to h - 1 do
for px := 0 to w - 1 do SrcIntfImg.Colors[px, py] := colRed;
e := GetTickCount - s;
Edit3.Text:=InttoStr(e);
SrcIntfImg.Free;
//LazIntfImg2
SrcIntfImg := TLazIntfImage.Create(0, 0);
SrcIntfImg.DataDescription := GetDescriptionFromDevice(0);
SrcIntfImg.SetSize(w, h);
s := GetTickCount;
for i:=0 to l do
for py := 0 to h - 1 do
begin
Row := SrcIntfImg.GetDataLineStart(py);
for px := 0 to w - 1 do
begin
row^[px].rgbtBlue :=0;
row^[px].rgbtGreen:=0;
row^[px].rgbtRed :=255;
end;
end;
e := GetTickCount - s;
Edit4.Text:=InttoStr(e);
SrcIntfImg.Free;
//TBitmap
T2 := TBitmap.Create;
T2.Height := w;
T2.Width := h;
s := GetTickCount;
for i:=0 to l do
for py := 0 to h - 1 do
for px := 0 to w - 1 do T2.Canvas.Pixels[px, py] := clred;
e := GetTickCount - s;
Edit5.Text:=InttoStr(e);
T2.Free;
end;
initialization
{$I unit1.lrs}
end.
OpBitmap: 1326ms
LazIntfImg: 1139ms
LazIntfImg2: 515ms
TBitmap: 14913ms
Edit: Nun auch mit OP-Scanline (Quelltext und Anhänge sind geändert):
OpBitmap: 1326ms
OPScanline: 452ms
LazIntfImg: 1139ms
LazIntfImg2: 531ms
TBitmap: 14726ms