Skip to content

Commit

Permalink
Swap pixel values on Big Endian
Browse files Browse the repository at this point in the history
  • Loading branch information
kkopachev committed Jan 14, 2021
1 parent 9040770 commit 7e5df7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
assert_image_similar,
assert_image_similar_tofile,
hopper,
is_big_endian,
skip_unless_feature,
)

Expand Down Expand Up @@ -879,7 +878,6 @@ def test_strip_planar_16bit_RGBa(self):
with Image.open("Tests/images/tiff_strip_planar_16bit_RGBa.tiff") as im:
assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_old_style_jpeg(self):
infile = "Tests/images/old-style-jpeg-compression.tif"
with Image.open(infile) as im:
Expand Down
8 changes: 8 additions & 0 deletions src/libImaging/TiffDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ _decodeStripYCbCr(Imaging im, ImagingCodecState state, TIFF *tiff) {
goto decodeycbcr_err;
}

#if WORDS_BIGENDIAN
TIFFSwabArrayOfLong((UINT32 *)state->buffer, img.width * rows_to_read);
#endif

TRACE(("Decoded strip for row %d \n", state->y));

// iterate over each row in the strip and stuff data into image
Expand Down Expand Up @@ -609,6 +613,10 @@ ImagingLibTiffDecode(
state->errcode = IMAGING_CODEC_BROKEN;
goto decode_err;
}

#if WORDS_BIGENDIAN
TIFFSwabArrayOfLong((UINT32 *)state->buffer, tile_width * tile_length);
#endif
} else {
if (TIFFReadTile(tiff, (tdata_t)state->buffer, x, y, 0, plane) == -1) {
TRACE(("Decode Error, Tile at %dx%d\n", x, y));
Expand Down

0 comments on commit 7e5df7f

Please sign in to comment.