Sunday, August 07, 2022

[big-endian] unbreak graphics/freeimage

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
--- Makefile 4 Aug 2022 19:03:14 -0000 1.20
+++ Makefile 7 Aug 2022 21:27:51 -0000
@@ -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 -0000
+++ patches/patch-Source_FreeImage_PluginBMP_cpp 7 Aug 2022 21:27:51 -0000
@@ -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);
+ }
+

No comments:

Post a Comment