This may be a really stupid question, but can someone tell me the difference between creating a CGContextRef using UIGraphicsBeginImageContext and using CGBitmapContextCreate fo
According to Apple's UIKit Function Reference, which carries the cover date of the 15th November 2010, UIGraphicsBeginImageContext
and related functions should still be called on the main thread only. The same text is repeated in the developer documentation that comes with the latest Xcode, 3.2.5. However, it reports the same for UIGraphicsGetCurrentContext
which I explicitly understood to be thread safe now. My understanding was that only UIGraphicsGetCurrentContext
and the UIImage, UIColor and UIFont classes are now thread safe rather than the entirety of UIKit, but I'm unable to find a definitive reference.
Regardless, UIGraphicsBeginImageContext
is a UIKit wrapper that sits on top of CGBitmapContextCreate
and reduces its functionality. In particular you're limited to RGBA colour space images with a fixed component order (though it varies according to the iOS version) and cannot specify your own target buffer for drawing. So, for example, it's useless for doing a bunch of CoreGraphics composition and then posting the result off to OpenGL and unhelpful for piping graphics you've already got in some array form into CoreGraphics.
However, where the UIKit method supports the functionality you need and is safe to use, there is no inherent advantage to the CoreGraphics methods.