如何使用RGB数据创建CGImage?

Rea*_*ion 5 cocoa objective-c cgimage ios

谁能告诉我一个如何使用的明确例子

CGImageRef CGImageCreate 
(
   size_t width,
   size_t height,
   size_t bitsPerComponent,
   size_t bitsPerPixel,
   size_t bytesPerRow,
   CGColorSpaceRef colorspace,
   CGBitmapInfo bitmapInfo,
   CGDataProviderRef provider,
   const CGFloat decode[],
   bool shouldInterpolate,
   CGColorRenderingIntent intent
);
Run Code Online (Sandbox Code Playgroud)

我有一个CGFloat dataBuffer [width*height*3];

它包含图像的所有RGB数据.基本上,它从像素R(0,0),G(0,0),B(0,0),R(0,1)...到R(宽度,高度),G(宽度,高度) ,B(宽度,高度)

我知道图像的大小,宽x高.我如何使用我拥有的信息并创建CGImage?

请帮忙,谢谢

我发布了另一个包含上述问题的问题.nschmidt正确回答,这是链接

在Objective-C++ Cocoa中将RGB数据转换为位图

Rea*_*ion 1

我发布了包含上述问题的另一个问题。恩施密特回答正确,这是链接

在 Objective-C++ Cocoa 中将 RGB 数据转换为位图