diff --git a/Tests/images/ati1.dds b/Tests/images/ati1.dds new file mode 100644 index 000000000..dc9445d89 Binary files /dev/null and b/Tests/images/ati1.dds differ diff --git a/Tests/images/ati1.png b/Tests/images/ati1.png new file mode 100644 index 000000000..da475dfd7 Binary files /dev/null and b/Tests/images/ati1.png differ diff --git a/Tests/test_file_dds.py b/Tests/test_file_dds.py index 396bcb830..537302a09 100644 --- a/Tests/test_file_dds.py +++ b/Tests/test_file_dds.py @@ -10,6 +10,7 @@ from .helper import assert_image_equal, assert_image_equal_tofile, hopper TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds" TEST_FILE_DXT3 = "Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds" TEST_FILE_DXT5 = "Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.dds" +TEST_FILE_ATI1 = "Tests/images/ati1.dds" TEST_FILE_ATI2 = "Tests/images/ati2.dds" TEST_FILE_DX10_BC5_TYPELESS = "Tests/images/bc5_typeless.dds" TEST_FILE_DX10_BC5_UNORM = "Tests/images/bc5_unorm.dds" @@ -63,6 +64,18 @@ def test_sanity_dxt5(): assert_image_equal_tofile(im, TEST_FILE_DXT5.replace(".dds", ".png")) +def test_sanity_ati1(): + """Check ATI1 images can be opened""" + + with Image.open(TEST_FILE_ATI1) as im: + im.load() + + assert im.format == "DDS" + assert im.mode == "L" + assert im.size == (128, 128) + + assert_image_equal_tofile(im, TEST_FILE_ATI1.replace(".dds", ".png")) + def test_sanity_ati2(): """Check ATI2 images can be opened""" diff --git a/src/PIL/DdsImagePlugin.py b/src/PIL/DdsImagePlugin.py index 40b424772..0f2cce1e5 100644 --- a/src/PIL/DdsImagePlugin.py +++ b/src/PIL/DdsImagePlugin.py @@ -195,7 +195,7 @@ class DdsImageFile(ImageFile.ImageFile): elif fourcc == b"ATI1": self.pixel_format = "BC4" n = 4 - self.mode = "RGB" + self.mode = "L" elif fourcc == b"ATI2": self.pixel_format = "BC5" n = 5