Re: [big-endian] unbreak graphics/freeimage

2022-08-08 Thread Theo Buehler
On Sun, Aug 07, 2022 at 09:50:27PM -0400, George Koehler wrote:
> Hello ports list,
> 
> BE_ARCHS can't build graphics/freeimage, because its big-endian code
> gives errors like,
> 
> Source/FreeImage/PluginBMP.cpp:1422:14: error: use of undeclared identifier 
> 'bpp
> '
> } else if (bpp == 16) {
>^
> 
> This diff, from an upstream commit, fixes the build for me on
> big-endian powerpc and powerpc64.  It unblocks some other packages,
> at least graphics/imv (an image viewer).  I tried to run imv on
> powerpc, but it got stuck on the cpu and failed to show any image.
> I can view images with imv on little-endian amd64, after I built
> freeimage with this diff.
> 
> ok to commit this diff?

ok tb



[big-endian] unbreak graphics/freeimage

2022-08-07 Thread George Koehler
Hello ports list,

BE_ARCHS can't build graphics/freeimage, because its big-endian code
gives errors like,

Source/FreeImage/PluginBMP.cpp:1422:14: error: use of undeclared identifier 'bpp
'
} else if (bpp == 16) {
   ^

This diff, from an upstream commit, fixes the build for me on
big-endian powerpc and powerpc64.  It unblocks some other packages,
at least graphics/imv (an image viewer).  I tried to run imv on
powerpc, but it got stuck on the cpu and failed to show any image.
I can view images with imv on little-endian amd64, after I built
freeimage with this diff.

ok to commit this diff?

Index: Makefile
===
RCS file: /cvs/ports/graphics/freeimage/Makefile,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile
--- Makefile4 Aug 2022 19:03:14 -   1.20
+++ Makefile7 Aug 2022 21:27:51 -
@@ -3,7 +3,7 @@ COMMENT=c++ library for common image f
 DISTNAME=  FreeImage3180
 PKGNAME=   freeimage-3.18.0
 CATEGORIES=graphics
-REVISION=  0
+REVISION=  1
 
 SHARED_LIBS+=  freeimage   3.0
 
Index: patches/patch-Source_FreeImage_PluginBMP_cpp
===
RCS file: patches/patch-Source_FreeImage_PluginBMP_cpp
diff -N patches/patch-Source_FreeImage_PluginBMP_cpp
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-Source_FreeImage_PluginBMP_cpp7 Aug 2022 21:27:51 
-
@@ -0,0 +1,43 @@
+fixed PluginBMP, PluginDDS for compilation under Big Endian OS (see
+FREEIMAGE_BIGENDIAN)
+https://sourceforge.net/p/freeimage/svn/1809/
+
+Index: Source/FreeImage/PluginBMP.cpp
+--- Source/FreeImage/PluginBMP.cpp.orig
 Source/FreeImage/PluginBMP.cpp
+@@ -518,7 +518,7 @@ LoadWindowsBMP(FreeImageIO *io, fi_handle handle, int 
+   io->read_proc(FreeImage_GetPalette(dib), 
used_colors * sizeof(RGBQUAD), 1, handle);
+ #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
+   RGBQUAD *pal = FreeImage_GetPalette(dib);
+-  for(int i = 0; i < used_colors; i++) {
++  for(unsigned i = 0; i < used_colors; i++) {
+   INPLACESWAP(pal[i].rgbRed, 
pal[i].rgbBlue);
+   }
+ #endif
+@@ -1419,7 +1419,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle,
+ 
+   free(buffer);
+ #ifdef FREEIMAGE_BIGENDIAN
+-  } else if (bpp == 16) {
++  } else if (dst_bpp == 16) {
+   int padding = dst_pitch - dst_width * sizeof(WORD);
+   WORD pad = 0;
+   WORD pixel;
+@@ -1440,7 +1440,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle,
+   }
+ #endif
+ #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
+-  } else if (bpp == 24) {
++  } else if (dst_bpp == 24) {
+   int padding = dst_pitch - dst_width * sizeof(FILE_BGR);
+   DWORD pad = 0;
+   FILE_BGR bgr;
+@@ -1461,7 +1461,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle,
+   }
+   }
+   }
+-  } else if (bpp == 32) {
++  } else if (dst_bpp == 32) {
+   FILE_BGRA bgra;
+   for(unsigned y = 0; y < dst_height; y++) {
+   BYTE *line = FreeImage_GetScanLine(dib, y);
Index: patches/patch-Source_FreeImage_PluginDDS_cpp
===
RCS file: patches/patch-Source_FreeImage_PluginDDS_cpp
diff -N patches/patch-Source_FreeImage_PluginDDS_cpp
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-Source_FreeImage_PluginDDS_cpp7 Aug 2022 21:27:51 
-
@@ -0,0 +1,22 @@
+fixed PluginBMP, PluginDDS for compilation under Big Endian OS (see
+FREEIMAGE_BIGENDIAN)
+https://sourceforge.net/p/freeimage/svn/1809/
+
+Index: Source/FreeImage/PluginDDS.cpp
+--- Source/FreeImage/PluginDDS.cpp.orig
 Source/FreeImage/PluginDDS.cpp
+@@ -356,14 +356,6 @@ SwapHeader(DDSHEADER *header) {
+   for(int i=0; i<11; i++) {
+   SwapLong(>surfaceDesc.dwReserved1[i]);
+   }
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwSize);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwFlags);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwFourCC);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwRGBBitCount);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwRBitMask);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwGBitMask);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwBBitMask);
+-  SwapLong(>surfaceDesc.ddpfPixelFormat.dwRGBAlphaBitMask);
+   SwapLong(>surfaceDesc.ddsCaps.dwCaps1);
+