Created
January 2, 2012 17:14
-
-
Save albertz/1551404 to your computer and use it in GitHub Desktop.
SDL_image ImageIO color space fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 5e26e77b30bf IMG_ImageIO.m | |
--- a/IMG_ImageIO.m Sat Dec 31 13:34:24 2011 -0500 | |
+++ b/IMG_ImageIO.m Mon Jan 02 18:10:20 2012 +0100 | |
@@ -212,8 +212,25 @@ | |
CGContextRef bitmap_context; | |
CGBitmapInfo bitmap_info; | |
- CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); | |
- | |
+ | |
+ /* This sets up a color space that results in identical values | |
+ * as the image data itself, which is the same as the standalone | |
+ * libpng loader. | |
+ * Thanks to Allegro. :) | |
+ */ | |
+ CGFloat whitePoint[3] = { 1, 1, 1 }; | |
+ CGFloat blackPoint[3] = { 0, 0, 0 }; | |
+ CGFloat gamma[3] = { 2.2, 2.2, 2.2 }; | |
+ CGFloat matrix[9] = { | |
+ 1, 1, 1, | |
+ 1, 1, 1, | |
+ 1, 1, 1 | |
+ }; | |
+ CGColorSpaceRef color_space = | |
+ CGColorSpaceCreateCalibratedRGB( | |
+ whitePoint, blackPoint, gamma, matrix | |
+ ); | |
+ | |
if (alpha == kCGImageAlphaNone || | |
alpha == kCGImageAlphaNoneSkipFirst || | |
alpha == kCGImageAlphaNoneSkipLast) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment