mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
Merge c6915f717f
into b7e0570cb1
This commit is contained in:
commit
eed9cb038c
|
@ -6,6 +6,8 @@ import pytest
|
|||
|
||||
from PIL import Image
|
||||
|
||||
from .helper import assert_image_equal
|
||||
|
||||
|
||||
def test_load_raw() -> None:
|
||||
with Image.open("Tests/images/hopper.pcd") as im:
|
||||
|
@ -30,3 +32,8 @@ def test_rotated(orientation: int) -> None:
|
|||
f = BytesIO(data)
|
||||
with Image.open(f) as im:
|
||||
assert im.size == (512, 768)
|
||||
|
||||
with Image.open("Tests/images/hopper.pcd") as expected:
|
||||
assert_image_equal(
|
||||
im, expected.rotate(90 if orientation == 1 else 270, expand=True)
|
||||
)
|
||||
|
|
|
@ -43,16 +43,21 @@ class PcdImageFile(ImageFile.ImageFile):
|
|||
if orientation == 1:
|
||||
self.tile_post_rotate = 90
|
||||
elif orientation == 3:
|
||||
self.tile_post_rotate = -90
|
||||
self.tile_post_rotate = 270
|
||||
|
||||
self._mode = "RGB"
|
||||
self._size = (512, 768) if orientation in (1, 3) else (768, 512)
|
||||
self.tile = [ImageFile._Tile("pcd", (0, 0) + self.size, 96 * 2048)]
|
||||
self.tile = [ImageFile._Tile("pcd", (0, 0, 768, 512), 96 * 2048)]
|
||||
|
||||
def load_prepare(self) -> None:
|
||||
if self._im is None and self.tile_post_rotate:
|
||||
self.im = Image.core.new(self.mode, (768, 512))
|
||||
ImageFile.ImageFile.load_prepare(self)
|
||||
|
||||
def load_end(self) -> None:
|
||||
if self.tile_post_rotate:
|
||||
# Handle rotated PCDs
|
||||
self.im = self.im.rotate(self.tile_post_rotate)
|
||||
self.im = self.rotate(self.tile_post_rotate, expand=True).im
|
||||
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue
Block a user