Skip to content

Commit bc2a3bf

Browse files
authored
Merge pull request #448 from Tom94/fix-srgb-png
Fix explicitly srgb-tagged PNGs
2 parents 0ce3641 + fe1fea0 commit bc2a3bf

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/imageio/PngImageLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ Task<vector<ImageData>> PngImageLoader::load(istream& iStream, const fs::path&,
543543
resultData.nativeMetadata.chroma = rec709Chroma(); // default to Rec.709 primaries unless cHRM chunk says otherwise
544544

545545
int srgbIntent = 0;
546-
const bool hasChunkSrgb = png_get_sRGB(pngPtr, infoPtr, &srgbIntent) == PNG_INFO_iCCP;
546+
const bool hasChunkSrgb = png_get_sRGB(pngPtr, infoPtr, &srgbIntent) == PNG_INFO_sRGB;
547547

548548
double invGamma64 = 1.0 / 2.2;
549549
const bool hasChunkGama = png_get_gAMA(pngPtr, infoPtr, &invGamma64) == PNG_INFO_gAMA;

src/imageio/PngImageSaver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Task<void> PngImageSaver::save(ostream& oStream, const fs::path&, span<const uin
7878
png, info, imageSize.x(), imageSize.y(), 8, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT
7979
);
8080

81+
png_set_sRGB(png, info, 3 /* absolute colorimetric */);
82+
8183
png_write_info(png, info);
8284

8385
const auto stride = (size_t)imageSize.x() * nChannels;

0 commit comments

Comments
 (0)