Skip to content

Commit

Permalink
handle I;16 native endianness on big-endian machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Jun 12, 2023
1 parent 7317e58 commit 32da357
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/_imaging.c
Expand Up @@ -1571,7 +1571,22 @@ if (PySequence_Check(op)) { \
PyErr_SetString(PyExc_TypeError, must_be_sequence);
return NULL;
}
int endian = strncmp(image->mode, "I;16", 4) == 0 ? (strcmp(image->mode, "I;16B") == 0 ? 2 : 1) : 0;
// 0 = none, 1 = little, 2 = big
int endian = 0;
if (strncmp(image->mode, "I;16", 4) == 0) {
if (strcmp(image->mode, "I;16L") == 0) {
endian = 1;
} else if (strcmp(image->mode, "I;16B") == 0) {
endian = 2;
} else {
// native endianness
#ifdef WORDS_BIGENDIAN
endian = 2;
#else
endian = 1;
#endif
}
}
double value;
for (i = x = y = 0; i < n; i++) {
set_value_to_item(seq, i);
Expand Down

0 comments on commit 32da357

Please sign in to comment.