Fixed bug 1413 - Cannot load images with ImageIO enabled on Mac OS X
authorSam Lantinga <slouken@libsdl.org>
Tue, 01 Jan 2013 11:40:47 -0800
changeset 3403999783ed889
parent 339 2e4f9d95a8c8
child 341 18ab81286e51
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
IMG_ImageIO.m
     1.1 --- a/CHANGES	Thu Nov 22 13:10:41 2012 -0800
     1.2 +++ b/CHANGES	Tue Jan 01 11:40:47 2013 -0800
     1.3 @@ -1,4 +1,6 @@
     1.4  1.2.12:
     1.5 +mscott - 2012-02-06 19:40:23 PST
     1.6 + * Fixed image corruption when using ImageIO framework
     1.7  Sylvain - Thu Nov 22 13:09:59 PST 2012
     1.8   * Added extended XPM color table (disabled by default in IMG_xpm.c)
     1.9  Sam Lantinga - Thu Jan 19 23:18:09 EST 2012
     2.1 --- a/IMG_ImageIO.m	Thu Nov 22 13:10:41 2012 -0800
     2.2 +++ b/IMG_ImageIO.m	Tue Jan 01 11:40:47 2013 -0800
     2.3 @@ -217,13 +217,13 @@
     2.4  	 * libpng loader.
     2.5  	 * Thanks to Allegro. :)
     2.6  	 */
     2.7 -	CGFloat whitePoint[3] = { 1, 1, 1 };
     2.8 -	CGFloat blackPoint[3] = { 0, 0, 0 };
     2.9 +	CGFloat whitePoint[3] = { 0.950, 1.000, 1.089 };
    2.10 +	CGFloat blackPoint[3] = { 0.000, 0.000, 0.000 };
    2.11  	CGFloat gamma[3] = { 2.2, 2.2, 2.2 };
    2.12  	CGFloat matrix[9] = {
    2.13 -		1, 1, 1,
    2.14 -		1, 1, 1,
    2.15 -		1, 1, 1
    2.16 +		0.412, 0.213, 0.019,
    2.17 +		0.358, 0.715, 0.119,
    2.18 +		0.180, 0.072, 0.950
    2.19  	};
    2.20  	CGColorSpaceRef color_space =
    2.21  		CGColorSpaceCreateCalibratedRGB(