var
...
Procedure CreateNewWorkerTask (
var T: ITask; L:Integer);
begin
T := TTask.Create(
procedure ()
var
Ziel, Quelle : ^TRGBTriple;
x, y, Start, Stop: Integer; OK: Boolean;
begin
if L = 0
then Start := 0
else Start := L * (Bitmap.Height
div cpus);
if L = 0
then Stop := Bitmap.Height
div cpus
else Stop := (Bitmap.Height
div cpus) * (L+1);
if Stop > Bitmap.Height-1
then Stop := Bitmap.Height-1;
for y := Start
to Stop
do begin
Ziel := Bitmap.Scanline[y];
Quelle := Original.Scanline[y];
for x := 0
to (Bitmap.Width-1)
do begin
if IgnoreWhite
then begin
OK := (Quelle^.rgbtBlue <> 255)
or (Quelle^.rgbtGreen <> 255)
or (Quelle^.rgbtred <> 255);
end else begin
OK := True;
end;
if OK
then begin
Ziel^.rgbtBlue := ar[Quelle^.rgbtBlue];
Ziel^.rgbtred := ar[Quelle^.rgbtred];
Ziel^.rgbtGreen := ar[Quelle^.rgbtGreen];
end;
inc(Ziel);
inc(Quelle);
end;
end;
end
);
end;
begin
...
QB := Original.ScanLine[0];
// <-- Die
ZB := Bitmap.ScanLine[0];
// <-- und die Zeile im Code, dann keine Access-Violation
cpus := GetCPUCount
div GetCPULogicalProcessorCount;
// Hier in Delphi-Praxis gefunden
SetLength(myTasks, cpus);
for L := 0
to cpus-1
do begin
CreateNewWorkerTask (myTasks[L], L);
myTasks[L].Start;
end;
TTask.WaitForAll(myTasks);