mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
tif.c: fix endianness detection, props Schaich Alonso
This commit is contained in:
parent
6dc8a242df
commit
89518c4f01
@ -45,13 +45,6 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
|
||||||
#include <endian.h>
|
|
||||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
|
||||||
#define TIF_BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* PhotometricInterpretation */
|
/* PhotometricInterpretation */
|
||||||
#define TIF_PMI_WHITEISZERO 0
|
#define TIF_PMI_WHITEISZERO 0
|
||||||
#define TIF_PMI_BLACKISZERO 1
|
#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) {
|
INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) {
|
||||||
unsigned char fg[4], bg[4];
|
unsigned char fg[4], bg[4];
|
||||||
int i;
|
int i;
|
||||||
@ -351,11 +348,11 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
#ifdef TIF_BIG_ENDIAN
|
if (is_big_endian()) {
|
||||||
header.byte_order = 0x4D4D; // "MM" big-endian
|
header.byte_order = 0x4D4D; // "MM" big-endian
|
||||||
#else
|
} else {
|
||||||
header.byte_order = 0x4949; // "II" little-endian
|
header.byte_order = 0x4949; // "II" little-endian
|
||||||
#endif
|
}
|
||||||
header.identity = 42;
|
header.identity = 42;
|
||||||
header.offset = free_memory;
|
header.offset = free_memory;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user