From badc92079d40ae74e3a343ababdaca442e43b2dd Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 1 Apr 2024 15:24:40 +1100 Subject: [PATCH] Do not cast to bytes for set_as_raw() --- src/PIL/BlpImagePlugin.py | 4 ++-- src/PIL/DdsImagePlugin.py | 2 +- src/PIL/QoiImagePlugin.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PIL/BlpImagePlugin.py b/src/PIL/BlpImagePlugin.py index f0fbc8cc2..95e807781 100644 --- a/src/PIL/BlpImagePlugin.py +++ b/src/PIL/BlpImagePlugin.py @@ -341,7 +341,7 @@ class BLP1Decoder(_BLPBaseDecoder): if self._blp_encoding in (4, 5): palette = self._read_palette() data = self._read_bgra(palette) - self.set_as_raw(bytes(data)) + self.set_as_raw(data) else: msg = f"Unsupported BLP encoding {repr(self._blp_encoding)}" raise BLPFormatError(msg) @@ -412,7 +412,7 @@ class BLP2Decoder(_BLPBaseDecoder): msg = f"Unknown BLP compression {repr(self._blp_compression)}" raise BLPFormatError(msg) - self.set_as_raw(bytes(data)) + self.set_as_raw(data) class BLPEncoder(ImageFile.PyEncoder): diff --git a/src/PIL/DdsImagePlugin.py b/src/PIL/DdsImagePlugin.py index b89502d1f..93c8e341d 100644 --- a/src/PIL/DdsImagePlugin.py +++ b/src/PIL/DdsImagePlugin.py @@ -506,7 +506,7 @@ class DdsRgbDecoder(ImageFile.PyDecoder): data += o8( int(((masked_value >> mask_offsets[i]) / mask_totals[i]) * 255) ) - self.set_as_raw(bytes(data)) + self.set_as_raw(data) return -1, 0 diff --git a/src/PIL/QoiImagePlugin.py b/src/PIL/QoiImagePlugin.py index 1a2a4d388..e9fef37a9 100644 --- a/src/PIL/QoiImagePlugin.py +++ b/src/PIL/QoiImagePlugin.py @@ -98,7 +98,7 @@ class QoiDecoder(ImageFile.PyDecoder): if bands == 3: value = value[:3] data += value - self.set_as_raw(bytes(data)) + self.set_as_raw(data) return -1, 0