⚡ Encode multimaps from scanlines instead of canvas pixels
Reading the canvas per pixel made writing a multimap orders of magnitude slower than necessary.
This commit is contained in:
+6
-2
@@ -120,6 +120,7 @@ var
|
||||
height, width, x, y: Integer;
|
||||
run: Byte;
|
||||
state, newState: Boolean;
|
||||
row: PByte;
|
||||
|
||||
procedure DoWrite;
|
||||
var
|
||||
@@ -136,13 +137,16 @@ begin
|
||||
Data.Write(width, SizeOf(Integer));
|
||||
Data.Write(height, SizeOf(Integer));
|
||||
run := 0;
|
||||
state := not (FGraphic.Canvas.Pixels[0,0] = clWhite);
|
||||
state := True;
|
||||
if (width > 0) and (height > 0) then
|
||||
state := (PByte(FGraphic.ScanLine[0])[0] and $80) = 0;
|
||||
if Assigned(FOnProgress) then FOnProgress(0, 0);
|
||||
for y := 0 to height - 1 do
|
||||
begin
|
||||
row := FGraphic.ScanLine[y];
|
||||
for x := 0 to width - 1 do
|
||||
begin
|
||||
newState := not (FGraphic.Canvas.Pixels[x,y] = clWhite);
|
||||
newState := (row[x shr 3] and ($80 shr (x and 7))) = 0;
|
||||
if (state = newState) and (run < $7F) then
|
||||
begin
|
||||
inc(run);
|
||||
|
||||
Reference in New Issue
Block a user