mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-21 04:34:47 +03:00
Fixed I;16 conversion on big endian
This commit is contained in:
parent
591e79e01e
commit
9b0192826a
|
@ -13,7 +13,6 @@ from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
hopper,
|
hopper,
|
||||||
is_big_endian,
|
|
||||||
is_win32,
|
is_win32,
|
||||||
mark_if_feature_version,
|
mark_if_feature_version,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
|
@ -77,7 +76,6 @@ class TestFilePng:
|
||||||
png.crc(cid, s)
|
png.crc(cid, s)
|
||||||
return chunks
|
return chunks
|
||||||
|
|
||||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
|
||||||
def test_sanity(self, tmp_path):
|
def test_sanity(self, tmp_path):
|
||||||
|
|
||||||
# internal version number
|
# internal version number
|
||||||
|
|
|
@ -963,10 +963,17 @@ static struct {
|
||||||
|
|
||||||
{"HSV", "RGB", hsv2rgb},
|
{"HSV", "RGB", hsv2rgb},
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
{"I", "I;16", I_I16B},
|
||||||
|
{"I;16", "I", I16B_I},
|
||||||
|
{"L", "I;16", L_I16B},
|
||||||
|
{"I;16", "L", I16B_L},
|
||||||
|
#else
|
||||||
{"I", "I;16", I_I16L},
|
{"I", "I;16", I_I16L},
|
||||||
{"I;16", "I", I16L_I},
|
{"I;16", "I", I16L_I},
|
||||||
{"L", "I;16", L_I16L},
|
{"L", "I;16", L_I16L},
|
||||||
{"I;16", "L", I16L_L},
|
{"I;16", "L", I16L_L},
|
||||||
|
#endif
|
||||||
|
|
||||||
{"I", "I;16L", I_I16L},
|
{"I", "I;16L", I_I16L},
|
||||||
{"I;16L", "I", I16L_I},
|
{"I;16L", "I", I16L_I},
|
||||||
|
|
|
@ -181,21 +181,11 @@ ImagingGetExtrema(Imaging im, void *extrema) {
|
||||||
case IMAGING_TYPE_SPECIAL:
|
case IMAGING_TYPE_SPECIAL:
|
||||||
if (strcmp(im->mode, "I;16") == 0) {
|
if (strcmp(im->mode, "I;16") == 0) {
|
||||||
UINT16 v;
|
UINT16 v;
|
||||||
UINT8 *pixel = *im->image8;
|
memcpy(&v, *im->image8, sizeof(v));
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
v = pixel[0] + (pixel[1] << 8);
|
|
||||||
#else
|
|
||||||
memcpy(&v, pixel, sizeof(v));
|
|
||||||
#endif
|
|
||||||
imin = imax = v;
|
imin = imax = v;
|
||||||
for (y = 0; y < im->ysize; y++) {
|
for (y = 0; y < im->ysize; y++) {
|
||||||
for (x = 0; x < im->xsize; x++) {
|
for (x = 0; x < im->xsize; x++) {
|
||||||
pixel = (UINT8 *)im->image[y] + x * sizeof(v);
|
memcpy(&v, im->image[y] + x * sizeof(v), sizeof(v));
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
v = pixel[0] + (pixel[1] << 8);
|
|
||||||
#else
|
|
||||||
memcpy(&v, pixel, sizeof(v));
|
|
||||||
#endif
|
|
||||||
if (imin > v) {
|
if (imin > v) {
|
||||||
imin = v;
|
imin = v;
|
||||||
} else if (imax < v) {
|
} else if (imax < v) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user