diff --git a/UOLib/UArt.pas b/UOLib/UArt.pas index 3cffa41..5b7b3cd 100644 --- a/UOLib/UArt.pas +++ b/UOLib/UArt.pas @@ -233,7 +233,7 @@ end; procedure TArt.RefreshBuffer; var argbGraphic: TSingleImage; - i, x, y, lineWidth, start: Integer; + i, y, lineWidth, start: Integer; iCurrentHeight, iCurrentWidth: Integer; width, height: SmallInt; color, run, offset: Word; @@ -246,27 +246,32 @@ begin FBuffer.Size := 0; if FArtType = atLand then begin - if (argbGraphic.Height <> 44) or (argbGraphic.Width <> 44) then Exit; - x := 21; + if (argbGraphic.Height <> 44) or (argbGraphic.Width <> 44) then + begin + argbGraphic.Free; + Exit; + end; y := 0; lineWidth := 2; for i := 1 to 22 do begin - Dec(x); - FBuffer.Write(PWordArray(argbGraphic.Bits + y * 44 * 2)^[x + i], lineWidth); + FBuffer.Write(PWordArray(argbGraphic.Bits + y * 44 * 2)^[22 - i], lineWidth); Inc(y); Inc(lineWidth, 2); end; for i := 1 to 22 do begin Dec(lineWidth, 2); - FBuffer.Write(PWordArray(argbGraphic.Bits + y * 44 * 2)^[x + i], lineWidth); - Inc(x); + FBuffer.Write(PWordArray(argbGraphic.Bits + y * 44 * 2)^[i - 1], lineWidth); Inc(y); end; end else if FArtType = atStatic then begin - if (argbGraphic.Height = 0) or (argbGraphic.Width = 0) then Exit; + if (argbGraphic.Height = 0) or (argbGraphic.Width = 0) then + begin + argbGraphic.Free; + Exit; + end; width := argbGraphic.Width; height := argbGraphic.Height; FBuffer.Write(FHeader, SizeOf(LongInt)); @@ -283,7 +288,7 @@ begin run := 0; for iCurrentWidth := 0 to width - 1 do //process every pixel on the current line begin - color := PWordArray(FGraphic.Bits + iCurrentHeight * width * 2)^[iCurrentWidth]; + color := PWordArray(argbGraphic.Bits + iCurrentHeight * width * 2)^[iCurrentWidth]; if (color and $8000 = 0) and (run = 0) then //new visible pixel found begin FBuffer.Write(offset, SizeOf(Word));