On May 17, 2005, at 9:44 AM, Brendan Younger wrote: 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.
This is only true on Tiger. 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.
Currently on OS X, everything gets matched to the colorspace of the main display. What happens when a window straddles 2 displays - apps do not re-render the content in a device loop. For apps that to handle the multi-display case, there are APIs to get this information and match to the non-main-display. 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.
You should try this out in Tiger to see if you still have problems.
Brendan Younger _______________________________________________ Do not post admin requests to the list. They will be ignored. Help/Unsubscribe/Update your Subscription:
|