From 25b51d0bebb34aea731dc702a9172c6390bae99c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 1 Jan 2013 11:40:47 -0800 Subject: [PATCH] Fixed bug 1413 - Cannot load images with ImageIO enabled on Mac OS X The attached diff fixes the library so ImageIO can be used and images are displayed again without corruption and black screens. (Based on http://pastebin.com/T3s15UXF and http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html) I suspect the matrix passed to CGColorSpaceCreateCalibratedRGB() as implemented in r292 is invalid and the CoreGraphics framework on 10.5 doesn't reject it, but later ones do. Unfortunately all the documentation I can find doesn't actually specify what the valid range of values of the arguments is. --- CHANGES | 2 ++ IMG_ImageIO.m | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 70efd764..4750739a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ 1.2.12: +mscott - 2012-02-06 19:40:23 PST + * Fixed image corruption when using ImageIO framework Sylvain - Thu Nov 22 13:09:59 PST 2012 * Added extended XPM color table (disabled by default in IMG_xpm.c) Sam Lantinga - Thu Jan 19 23:18:09 EST 2012 diff --git a/IMG_ImageIO.m b/IMG_ImageIO.m index 30795871..d2151676 100644 --- a/IMG_ImageIO.m +++ b/IMG_ImageIO.m @@ -217,13 +217,13 @@ static CFDictionaryRef CreateHintDictionary(CFStringRef uti_string_hint) * libpng loader. * Thanks to Allegro. :) */ - CGFloat whitePoint[3] = { 1, 1, 1 }; - CGFloat blackPoint[3] = { 0, 0, 0 }; + CGFloat whitePoint[3] = { 0.950, 1.000, 1.089 }; + CGFloat blackPoint[3] = { 0.000, 0.000, 0.000 }; CGFloat gamma[3] = { 2.2, 2.2, 2.2 }; CGFloat matrix[9] = { - 1, 1, 1, - 1, 1, 1, - 1, 1, 1 + 0.412, 0.213, 0.019, + 0.358, 0.715, 0.119, + 0.180, 0.072, 0.950 }; CGColorSpaceRef color_space = CGColorSpaceCreateCalibratedRGB(