Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User Spaces vs. Generic Spaces




On May 17, 2005, at 11:21 AM, Andrew Kimpton wrote:


On May 16, 2005, at 2:39 PM, Scott Thompson wrote:

Your best bet would be to read the images and perform the color management on them once, then repeatedly draw the modified images.  There are several strategies you might take to do this.

If you  support 10.3 and above, you can probably get away with using CGImageCreateCopyWithColorSpace.  As you read in each image, create a copy and change the color space to the generic RGB space, or the color space of your monitor.




10.3 is our minimum, so this sounds like the best trick to avoiding the performance hit.

Now that I read what I wrote again, this is precisely the wrong idea.  (Sorry!)

What you want to do is color match the image from sRGB to the monitor or generic rgb color space.  This routine is just going to give you a copy of the image with the color space object replaced with the one you pass in.  That's not going to color match the image at all!  (what was I thinking)

You'll probably have to do the "redraw the image into a bitmap" thing to get Quartz to color match the data for you.


Ok - so if I have a CGImage in my left hand that is in the sRGB colorspace, and I have a CGContext pointing at the display with the generic colorspace (or DeviceRGB) in my right hand. Every time I draw the image from left to right I incur a performance hit for the color space transform ?

Possibly, but usually CoreGraphics is smart enough to cache a copy of the image which has already been transformed.  If you don't release the CGImageRef, that is.

However if I insert an intermediate CGImage/CGBitmapContext combo with a colorspace matching the displays CGContext and draw the image once to the intermediate (incurring the performance hit one time only) I can draw that intermediate multiple times later without incurring the hit ?

Yes, that will work, but it should be largely unnecessary.  Also note that the notion of the "display" color space is a little fuzzy since users can have multiple monitors, so you might very well choose the wrong monitor's color space and then be back where you started.

I'm actually already doing something very close to this since the original CGImage comes from a 'PNG Data Provider' which is slow if you draw it multiple times (disk rereads - an issue mentioned here in the past). Since my images aren't color corrected I can only assume that somewhere along the line the sRGB colorspace info is either not present, being ignored, or being overwritten by a colorspace set by my own code.

PNGs are by default in sRGB.  If your image isn't being color-corrected, then you're either drawing it into a CGContext with a device RGB colorspace on 10.3 or earlier or there is a bug in the PNG reading code that doesn't tag the resulting image properly.  File a bug if this is the case.

Brendan Younger
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden

References: 
 >User Spaces vs. Generic Spaces (From: "R. Scott Thompson" <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Brendan Younger <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Haroon Sheikh <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Andrew Kimpton <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Scott Thompson <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Andrew Kimpton <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Scott Thompson <email@hidden>)
 >Re: User Spaces vs. Generic Spaces (From: Andrew Kimpton <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.