在目前(iOS4.3版本已经出来了)cocoa没有提供从CGimage到bitmap的接口,想得到bitmap还得费一番周折。以下是我从苹果开发者网站上找到的一段,可以实现。大体思路为:先创建满足自己要求的Context,再将原图片画到Context上,然后再从Context上得到图片的bitmap数据。
原文:http://developer.apple.com/library/ios/#qa/qa1509/_index.html
creates a bitmap context with a 8-bits per component ARGB color space, draws the source image to this context, then retrieves the image bits in this color space from the context. Regardless of what the source image format is (CMYK, 24-bit RGB, Grayscale, and so on) it will be converted over to this color space.
For more information about creating bitmap contexts for other pixel formats, see the