From f4275217bbf328fa42d8c20951f5a6262d79c25d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 15 Nov 2026 08:55:56 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Encode=20multimaps=20from=20scanlin?= =?UTF-8?q?es=20instead=20of=20canvas=20pixels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading the canvas per pixel made writing a multimap orders of magnitude slower than necessary. --- UOLib/UMultiMap.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/UOLib/UMultiMap.pas b/UOLib/UMultiMap.pas index f3874cb..6111eea 100644 --- a/UOLib/UMultiMap.pas +++ b/UOLib/UMultiMap.pas @@ -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);