Skip to content

Commit

Permalink
Corrected DdsImagePlugin setting info gamma
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 30, 2019
1 parent bb1fc75 commit d716278
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Binary file added Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds
Binary file not shown.
Binary file added Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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_DX10_BC7 = "Tests/images/bc7-argb-8bpp_MipMaps-1.dds"
TEST_FILE_DX10_BC7_UNORM_SRGB = "Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds"
TEST_FILE_UNCOMPRESSED_RGB = "Tests/images/uncompressed_rgb.dds"


Expand Down Expand Up @@ -69,6 +70,21 @@ def test_dx10_bc7(self):

self.assert_image_equal(target, im)

def test_dx10_bc7_unorm_srgb(self):
"""Check DX10 unsigned normalized integer images can be opened"""

target = Image.open(TEST_FILE_DX10_BC7_UNORM_SRGB.replace(".dds", ".png"))

im = Image.open(TEST_FILE_DX10_BC7_UNORM_SRGB)
im.load()

self.assertEqual(im.format, "DDS")
self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (16, 16))
self.assertEqual(im.info["gamma"], 1 / 2.2)

self.assert_image_equal(target, im)

def test_unimplemented_dxgi_format(self):
self.assertRaises(
NotImplementedError,
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _open(self):
n = 7
elif dxgi_format == DXGI_FORMAT_BC7_UNORM_SRGB:
self.pixel_format = "BC7"
self.im_info["gamma"] = 1 / 2.2
self.info["gamma"] = 1 / 2.2
n = 7
else:
raise NotImplementedError(
Expand Down

0 comments on commit d716278

Please sign in to comment.