对于具有 alpha 透明度的 pngcrunch 优化的 24 位 PNG 文件,我必须为每个组件指定多少位?

发布于 2024-07-20 00:39:19 字数 360 浏览 6 评论 0原文

CGBitmapContextCreate 采用的参数对我来说不是很明显:

例如,对于 32 位像素格式 和 RGB 色彩空间,你会 指定每 8 位的值 组件。

我创建了带有 alphatransparency 的 24 位 PNG 文件,并将它们添加到 Xcode 中。 在编译时,Xcode 使用 pngcrunch 优化这些 PNG 图块。

因此,当尝试在 iPhone-OS 上从此类图像文件创建图形上下文时,我需要指定每个组件的位数。

在这种情况下,我会说它们每个组件 4 位,尽管我不知道 alpha 是否算作一个组件。

CGBitmapContextCreate takes an parameter that's not very obvious to me:

For example, for a 32-bit pixel format
and an RGB color space, you would
specify a value of 8 bits per
component.

I have created 24-bit PNG files with alphatransparency, and added them to Xcode. At compile time, Xcode optimizes those PNG tiles with pngcrunch.

So, when trying to make an graphics context out of such an image file on iPhone-OS, I need to specify the bits per component.

In this case, I would say they're 4 bits per component, although I dont know if alpha counts as an component.

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

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

发布评论

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

评论(1

追风人 2024-07-27 00:39:19

每个组件 8 位:

Red:8;
Green:8;
Blue:8;
Alpha:8;

每个像素加起来为 32 位。 具有透明度的 24 位 png 是 24 位 RGB,加上 8 位透明度(“alpha 通道”)。

It's 8 bits per component:

Red:8;
Green:8;
Blue:8;
Alpha:8;

That adds up to 32 bits per pixel. Your 24-bit png with transparency is 24-bits for RGB, plus 8 bits for transparency (the 'alpha channel').

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