From: DeaDDooMER Date: Sun, 6 Oct 2019 14:03:22 +0000 (+0300) Subject: vampimg endianess fixes X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=976db3db1ae1d95076480d29b46864453804449f;p=d2df-sdl.git vampimg endianess fixes --- diff --git a/src/lib/vampimg/ImagingTarga.pas b/src/lib/vampimg/ImagingTarga.pas index 66af5f2..921f009 100644 --- a/src/lib/vampimg/ImagingTarga.pas +++ b/src/lib/vampimg/ImagingTarga.pas @@ -197,6 +197,12 @@ begin begin // Read targa header Read(Handle, @Hdr, SizeOf(Hdr)); + Hdr.ColorMapOff := LEtoN(Hdr.ColorMapOff); + Hdr.ColorMapLength := LEtoN(Hdr.ColorMapLength); + Hdr.XOrg := LEtoN(Hdr.XOrg); + Hdr.YOrg := LEtoN(Hdr.YOrg); + Hdr.Width := LEtoN(Hdr.Width); + Hdr.Height := LEtoN(Hdr.Height); // Skip image ID info Seek(Handle, Hdr.IDLength, smFromCurrent); // Determine image format diff --git a/src/lib/vampimg/ImagingUtility.pas b/src/lib/vampimg/ImagingUtility.pas index c137e1d..1fb47dd 100644 --- a/src/lib/vampimg/ImagingUtility.pas +++ b/src/lib/vampimg/ImagingUtility.pas @@ -1093,6 +1093,8 @@ begin Result := PByte(@W)^ = $FF; end; +(* Vampimp wrongly use swaps for converting big-endian to little-endian anywhere *) +{$IF DEFINED(FPC_LITTLE_ENDIAN)} function SwapEndianWord(Value: Word): Word; {$IF Defined(USE_ASM) and (not Defined(USE_INLINE))} asm @@ -1170,6 +1172,27 @@ begin end; end; {$ENDIF} +{$ELSEIF DEFINED(FPC_BIG_ENDIAN)} +function SwapEndianWord(Value: Word): Word; +begin + Result := Value +end; + +procedure SwapEndianWord(P: PWordArray; Count: LongInt); +begin +end; + +function SwapEndianLongWord(Value: LongWord): LongWord; +begin + Result := Value +end; + +procedure SwapEndianLongWord(P: PLongWord; Count: LongInt); +begin +end; +{$ELSE} + {$ERROR Unsupported endianness!} +{$ENDIF} type TCrcTable = array[Byte] of LongWord;