Skip to content

Commit

Permalink
Only unpack masks when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 30, 2023
1 parent 5fd3035 commit 8814610
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ def _open(self):

# pixel format
pfsize, pfflags, fourcc, bitcount = struct.unpack("<4I", header.read(16))
masks = struct.unpack("<4I", header.read(16))
n = 0
rawmode = None
if pfflags & DDPF.RGB:
# Texture contains uncompressed RGB data
masks = struct.unpack("<4I", header.read(16))
masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
if bitcount == 8:
self._mode = "L"
Expand Down

0 comments on commit 8814610

Please sign in to comment.