mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-01 15:48:25 -04:00
tif.c: fix endianness detection, props Schaich Alonso
This commit is contained in:
parent
6dc8a242df
commit
89518c4f01
1 changed files with 9 additions and 12 deletions
|
@ -45,13 +45,6 @@
|
|||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
#include <endian.h>
|
||||
# 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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue