diff --git a/backend/tif.c b/backend/tif.c index f0000efb..a950e122 100644 --- a/backend/tif.c +++ b/backend/tif.c @@ -45,13 +45,6 @@ #include #endif -#if !defined(_WIN32) && !defined(__APPLE__) -#include -# if __BYTE_ORDER == __BIG_ENDIAN -#define TIF_BIG_ENDIAN -#endif -#endif - /* PhotometricInterpretation */ #define TIF_PMI_WHITEISZERO 0 #define TIF_PMI_BLACKISZERO 1 @@ -85,6 +78,10 @@ static void to_cmyk(unsigned char rgb[3], unsigned char alpha, unsigned char *cm } +static int is_big_endian() { + return (*((const uint16_t *)"\x11\x22") == 0x1122); +} + INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { unsigned char fg[4], bg[4]; int i; @@ -351,11 +348,11 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } /* Header */ -#ifdef TIF_BIG_ENDIAN - header.byte_order = 0x4D4D; // "MM" big-endian -#else - header.byte_order = 0x4949; // "II" little-endian -#endif + if (is_big_endian()) { + header.byte_order = 0x4D4D; // "MM" big-endian + } else { + header.byte_order = 0x4949; // "II" little-endian + } header.identity = 42; header.offset = free_memory;