如何使用 RGB 数据创建 CGImage?

发布于 2024-08-08 00:00:17 字数 805 浏览 3 评论 0原文

谁能告诉我一个如何使用的清晰示例

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幸福%小乖 2024-08-15 00:00:17

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

一些不太神秘的事情是传递给 colorSpacebitmapInfo 的内容。它们是一个 CGColorSpace 对象和一个 CGBitmapInfo 位掩码。

decode 数组的解释可能会更清楚,但明确的是您可能不需要它。传递NULL

除了这些之外,一切都是不言而喻的,或者在 中得到了很好的解释该函数的文档

The biggest mystery there is the data provider. The answer for that is that you need to create a CGDataProvider object that either contains or can provide the pixel data you have.

Some lesser mysteries are what to pass for colorSpace and bitmapInfo. Those are a CGColorSpace object and a CGBitmapInfo bit-mask.

The explanation of the decode array could be clearer, but what is clear is that you probably don't need one. Pass NULL.

Aside from those things, everything is either self-evident or well-explained in the documentation for this function.

这个俗人 2024-08-15 00:00:17

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文