Skip to content

Commit

Permalink
Replace self.mode with self._mode
Browse files Browse the repository at this point in the history
  • Loading branch information
REDxEYE committed Oct 12, 2023
1 parent 2a6bcc1 commit 69b922d
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ def _open(self):
masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
if bitcount == 24:
rawmode = masks[0x00FF0000] + masks[0x0000FF00] + masks[0x000000FF]
self.mode = "RGB"
self._mode = "RGB"
self.tile = [("raw", extents, 0, (rawmode[::-1], 0, 1))]
elif bitcount == 32 and pfflags & DDPF.ALPHAPIXELS:
self.mode = "RGBA"
self._mode = "RGBA"
rawmode = (
masks[0xFF000000]
+ masks[0x00FF0000]
Expand All @@ -390,17 +390,17 @@ def _open(self):
raise OSError(msg)

Check warning on line 390 in src/PIL/DdsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/DdsImagePlugin.py#L389-L390

Added lines #L389 - L390 were not covered by tests
elif pfflags & DDPF.ALPHA:
if bitcount == 8:
self.mode = "L"
self._mode = "L"
self.tile = [("raw", extents, 0, ("L", 0, 1))]

Check warning on line 394 in src/PIL/DdsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/DdsImagePlugin.py#L392-L394

Added lines #L392 - L394 were not covered by tests
else:
msg = f"Unsupported bitcount {bitcount} for {pfflags_}"
raise OSError(msg)

Check warning on line 397 in src/PIL/DdsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/DdsImagePlugin.py#L396-L397

Added lines #L396 - L397 were not covered by tests
elif pfflags & DDPF.LUMINANCE:
if bitcount == 8:
self.mode = "L"
self._mode = "L"
self.tile = [("raw", extents, 0, ("L", 0, 1))]
elif bitcount == 16 and pfflags & DDPF.ALPHAPIXELS:
self.mode = "LA"
self._mode = "LA"
self.tile = [("raw", extents, 0, ("LA", 0, 1))]
else:
msg = f"Unsupported bitcount {bitcount} for {pfflags_}"
Expand All @@ -417,31 +417,31 @@ def _open(self):
msg = f"Unimplemented pixel format {repr(fourcc_)}"
raise NotImplementedError(msg)
if fourcc == D3DFMT.DXT1:
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "DXT1"
tile = Image._Tile("bcn", extents, data_offs, (1, self.pixel_format))
elif fourcc == D3DFMT.DXT3:
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "DXT3"
tile = Image._Tile("bcn", extents, data_offs, (2, self.pixel_format))
elif fourcc == D3DFMT.DXT5:
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "DXT5"
tile = Image._Tile("bcn", extents, data_offs, (3, self.pixel_format))
elif fourcc == D3DFMT.ATI1 or fourcc == D3DFMT.BC4U:
self.mode = "L"
self._mode = "L"
self.pixel_format = "BC4"
tile = Image._Tile("bcn", extents, data_offs, (4, self.pixel_format))
elif fourcc == D3DFMT.BC5S:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC5S"
tile = Image._Tile("bcn", extents, data_offs, (5, self.pixel_format))
elif fourcc == D3DFMT.BC5U:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC5U"
tile = Image._Tile("bcn", extents, data_offs, (5, self.pixel_format))
elif fourcc == D3DFMT.ATI2:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC5"
tile = Image._Tile("bcn", extents, data_offs, (5, self.pixel_format))
elif fourcc == D3DFMT.DX10:
Expand All @@ -454,43 +454,43 @@ def _open(self):
DXGI_FORMAT.BC1_UNORM_SRGB,
DXGI_FORMAT.BC1_TYPELESS,
):
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "BC1"
tile = Image._Tile(

Check warning on line 459 in src/PIL/DdsImagePlugin.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/DdsImagePlugin.py#L457-L459

Added lines #L457 - L459 were not covered by tests
"bcn", extents, data_offs, (1, self.pixel_format)
)
elif dxgi_format in (DXGI_FORMAT.BC5_TYPELESS, DXGI_FORMAT.BC5_UNORM):
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC5"
tile = Image._Tile(
"bcn", extents, data_offs, (5, self.pixel_format)
)
elif dxgi_format == DXGI_FORMAT.BC5_SNORM:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC5S"
tile = Image._Tile(
"bcn", extents, data_offs, (5, self.pixel_format)
)
elif dxgi_format == DXGI_FORMAT.BC6H_UF16:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC6H"
tile = Image._Tile(
"bcn", extents, data_offs, (6, self.pixel_format)
)
elif dxgi_format == DXGI_FORMAT.BC6H_SF16:
self.mode = "RGB"
self._mode = "RGB"
self.pixel_format = "BC6HS"
tile = Image._Tile(
"bcn", extents, data_offs, (6, self.pixel_format)
)
elif dxgi_format in (DXGI_FORMAT.BC7_TYPELESS, DXGI_FORMAT.BC7_UNORM):
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "BC7"
tile = Image._Tile(
"bcn", extents, data_offs, (7, self.pixel_format)
)
elif dxgi_format == DXGI_FORMAT.BC7_UNORM_SRGB:
self.mode = "RGBA"
self._mode = "RGBA"
self.pixel_format = "BC7"
self.info["gamma"] = 1 / 2.2
tile = Image._Tile(
Expand All @@ -501,7 +501,7 @@ def _open(self):
DXGI_FORMAT.R8G8B8A8_UNORM,
DXGI_FORMAT.R8G8B8A8_UNORM_SRGB,
):
self.mode = "RGBA"
self._mode = "RGBA"
tile = Image._Tile("raw", extents, 0, ("RGBA", 0, 1))
if dxgi_format == DXGI_FORMAT.R8G8B8A8_UNORM_SRGB:
self.info["gamma"] = 1 / 2.2
Expand Down

0 comments on commit 69b922d

Please sign in to comment.