如何用RGB数据创建CGImage?(How do I create a CGImage with RGB data?)

编程入门 行业动态 更新时间:2024-10-12 12:23:39
如何用RGB数据创建CGImage?(How do I create a CGImage with RGB data?)

任何人都可以向我展示如何使用的清晰示例

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 );

我有一个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数据转换为位图

Can anyone show me a clear example of how to use

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 );

I have a CGFloat dataBuffer [width * height * 3];

It contains all of the RGB data of the image. Essentially, it goes from pixel R (0,0), G (0,0), B(0,0), R(0,1)... to R(width, height), G(width,height), B(width,height)

I know the size of the image, width x height. How do I use the information that I have and create and CGImage??

Please help, thanks

I posted another question that encompasses the above question. It was answered correctly by nschmidt, here is the link

Converting RGB data into a bitmap in Objective-C++ Cocoa

最满意答案

数据提供者是最大的谜团。 答案是您需要创建一个CGDataProvider对象,该对象包含或可以提供您拥有的像素数据。

一些较小的奥秘是colorSpace和bitmapInfo传递的bitmapInfo 。 这些是CGColorSpace对象和CGBitmapInfo位掩码。

decode阵列的解释可能会更清晰,但很明显的是,您可能不需要一个decode阵列。 通过NULL 。

除了这些事情之外,所有事情都是不言而喻的,或者在这个函数的文档中有充分的解释。

I posted another question that encompasses the above question. It was answered correctly by nschmidt, here is the link

Converting RGB data into a bitmap in Objective-C++ Cocoa

更多推荐

本文发布于:2023-07-06 07:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047437.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何用   数据   RGB   data   CGImage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!