views:

248

answers:

1

I want to create a bitmap CGContext with the same color space as an existing CGContext. How can I get the color space of a CGContext?

+1  A: 

You need to call CGBitmapContextGetColorSpace to get the colour space of a given bitmap context,
but if you're talking about a general context then the question isn't well defined because CGContexts have two colour spaces: stroke and fill.

Rhythmic Fistman
How can I get color space for stroke or fill?What I want is to create a bitmap context for offline drawing, and then draw the bitmap context to current context.And I don't use CGLayer, because I don't want to cache it.
MQ Gu
I don't think you can. What's the worst that could happen if you don't set the colour space? p.s. Your colour space is probably DeviceRGB.
Rhythmic Fistman
It works. Thanks you very much!
MQ Gu