xref: /OK3568_Linux_fs/buildroot/package/libfreeimage/0003-fix-big-endian-os.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1fixed PluginBMP, PluginDDS for compilation under Big Endian OS
2
3Downloaded from upstream commit:
4https://sourceforge.net/p/freeimage/svn/1809/
5
6Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
7
8diff -uNr FreeImage.orig/Source/FreeImage/PluginBMP.cpp FreeImage/Source/FreeImage/PluginBMP.cpp
9--- FreeImage.orig/Source/FreeImage/PluginBMP.cpp	2016-06-15 12:35:30.000000000 +0200
10+++ FreeImage/Source/FreeImage/PluginBMP.cpp	2019-08-31 16:00:27.813378612 +0200
11@@ -518,7 +518,7 @@
12 				io->read_proc(FreeImage_GetPalette(dib), used_colors * sizeof(RGBQUAD), 1, handle);
13 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
14 				RGBQUAD *pal = FreeImage_GetPalette(dib);
15-				for(int i = 0; i < used_colors; i++) {
16+				for(unsigned int i = 0; i < used_colors; i++) {
17 					INPLACESWAP(pal[i].rgbRed, pal[i].rgbBlue);
18 				}
19 #endif
20@@ -1419,7 +1419,7 @@
21
22 			free(buffer);
23 #ifdef FREEIMAGE_BIGENDIAN
24-		} else if (bpp == 16) {
25+		} else if (dst_bpp == 16) {
26 			int padding = dst_pitch - dst_width * sizeof(WORD);
27 			WORD pad = 0;
28 			WORD pixel;
29@@ -1440,7 +1440,7 @@
30 			}
31 #endif
32 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
33-		} else if (bpp == 24) {
34+		} else if (dst_bpp == 24) {
35 			int padding = dst_pitch - dst_width * sizeof(FILE_BGR);
36 			DWORD pad = 0;
37 			FILE_BGR bgr;
38@@ -1461,7 +1461,7 @@
39 					}
40 				}
41 			}
42-		} else if (bpp == 32) {
43+		} else if (dst_bpp == 32) {
44 			FILE_BGRA bgra;
45 			for(unsigned y = 0; y < dst_height; y++) {
46 				BYTE *line = FreeImage_GetScanLine(dib, y);
47diff -uNr FreeImage.orig/Source/FreeImage/PluginDDS.cpp FreeImage/Source/FreeImage/PluginDDS.cpp
48--- FreeImage.orig/Source/FreeImage/PluginDDS.cpp	2018-07-31 17:04:58.000000000 +0200
49+++ FreeImage/Source/FreeImage/PluginDDS.cpp	2019-08-31 16:00:39.213465120 +0200
50@@ -356,14 +356,6 @@
51 	for(int i=0; i<11; i++) {
52 		SwapLong(&header->surfaceDesc.dwReserved1[i]);
53 	}
54-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwSize);
55-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwFlags);
56-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwFourCC);
57-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRGBBitCount);
58-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRBitMask);
59-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwGBitMask);
60-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwBBitMask);
61-	SwapLong(&header->surfaceDesc.ddpfPixelFormat.dwRGBAlphaBitMask);
62 	SwapLong(&header->surfaceDesc.ddsCaps.dwCaps1);
63 	SwapLong(&header->surfaceDesc.ddsCaps.dwCaps2);
64 	SwapLong(&header->surfaceDesc.ddsCaps.dwReserved[0]);
65