DEADSOFTWARE

libs: sync vampimg with d2df-sdl
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 22 May 2023 19:39:02 +0000 (22:39 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 22 May 2023 19:39:02 +0000 (22:39 +0300)
src/lib/vampimg/ImagingPcx.pas
src/lib/vampimg/ImagingTarga.pas
src/lib/vampimg/ImagingTypes.pas
src/lib/vampimg/ImagingUtility.pas
src/lib/vampimg/ZLib/dzlib.pas

index b85b5d2cf7500d09dc6480a4629df7ce78f88e5f..9379b8b84e312679a2d9818525dafef32d7cc021 100644 (file)
@@ -87,7 +87,6 @@ end;
 
 function TPCXFileFormat.LoadData(Handle: TImagingHandle;
   var Images: TDynImageDataArray; OnlyFirstLevel: Boolean): Boolean;
-
 var
   Hdr: TPCXHeader;
   PalID, B: Byte;
index 66af5f2c8b58b6cfc477f89ab67fbe5ad435a5ee..921f0097fac37bb5ce7e6a15670750c0c9d50002 100644 (file)
@@ -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
index f2fb26311182c5dc29af609d8d97cc4653624353..add9ca6f8d62d8abdcb89c4c9c37cc9c9653e819 100644 (file)
@@ -259,7 +259,7 @@ type
     ifETC2PA         = 223,
     ifDXBC6          = 224,
     ifDXBC7          = 225}
-    { PCX formats}
+    { PCX formats }
     ifMono           = 250,
     ifIndex2         = 251,
     ifIndex4         = 252
index c137e1d1386823beaaeefdd0d2aec47e21d5c93e..1fb47dd66f3005112c7056073fa77f3788e6909f 100644 (file)
@@ -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;
index 05e278d0fd78f5f5faf1dd64892422946f68deb9..337f310ecbb107946d9c2710c62f465a279b13da 100644 (file)
@@ -41,7 +41,7 @@
 
 unit dzlib;
 
-{$I ImagingOptions.inc}
+{$I ../ImagingOptions.inc}
 
 interface