From 4235169d417dabb4133578b3c396f53fb53a67e0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Oct 2012 12:00:53 +0000 Subject: [PATCH] From Gill Peacegood, "In the attached file I have changed the colour space used for writing images to match the one used for reading images. Also this color space does not make subtle changes to the original colours which i think is probably what most people intend when writing an image and is more consistent with other plugins. The effect is that an image that is written does not have a noticeably different colour when it is read back." --- src/osgPlugins/imageio/ReaderWriterImageIO.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp index 1712fd7ab..fd9a686fe 100644 --- a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp +++ b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp @@ -501,7 +501,8 @@ CGImageRef CreateCGImageFromOSGData(const osg::Image& osg_image) { bitmap_info = kCGImageAlphaNone; target_bytes_per_row = (image_width * 8 + 7)/8; - color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); + //color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); + color_space = CGColorSpaceCreateDeviceGray(); if(NULL == color_space) { return NULL; @@ -584,8 +585,9 @@ CGImageRef CreateCGImageFromOSGData(const osg::Image& osg_image) { bitmap_info = kCGImageAlphaNoneSkipFirst; target_bytes_per_row = (image_width * 8 * 4 + 7)/8; - color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - if(NULL == color_space) + //color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + color_space = CGColorSpaceCreateDeviceRGB(); + if(NULL == color_space) { OSG_WARN << "In CreateCGImageFromOSGData, CGColorSpaceCreateWithName failed" << std::endl; return NULL; @@ -638,7 +640,8 @@ CGImageRef CreateCGImageFromOSGData(const osg::Image& osg_image) { bitmap_info = kCGImageAlphaPremultipliedLast; target_bytes_per_row = osg_image.getRowSizeInBytes(); - color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + //color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + color_space = CGColorSpaceCreateDeviceRGB(); if(NULL == color_space) { OSG_WARN << "In CreateCGImageFromOSGData, CGColorSpaceCreateWithName failed" << std::endl; @@ -686,7 +689,8 @@ CGImageRef CreateCGImageFromOSGData(const osg::Image& osg_image) } target_bytes_per_row = osg_image.getRowSizeInBytes(); - color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + //color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + color_space = CGColorSpaceCreateDeviceRGB(); if(NULL == color_space) { OSG_WARN << "In CreateCGImageFromOSGData, CGColorSpaceCreateWithName failed" << std::endl;