有没有 c++ 的库(或工具)用 alpha 值减少 PNG 图像中的颜色?
我有一个带有 alpha 值的 PNG 图像,需要减少颜色数量。我需要图像中的所有颜色不超过 256 种颜色,到目前为止我尝试过的所有操作(从油漆店到 leptonica 等...)都会剥离图像的 Alpha 通道并使其无法使用。有什么东西可以满足我的要求吗?
编辑:我不想使用 8 位调色板。我只需要减少颜色的数量,以便我自己的程序可以处理图像。
I have a PNG-Image with alpha values and need to reduce the amount of colors. I need to have no more than 256 colors for all the colors in the image and so far everything I tried (from paint shop to leptonica, etc...) strips the image of the alpha channel and makes it unusable. Is there anything out there that does what I want ?
Edit: I do not want to use a 8-bit palette. I just need to reduce the numbers of color so that my own program can process the image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你试过ImageMagick吗?
Have you tried ImageMagick?
具有 Alpha 透明度的 8 位 PNG 只会在较新的网络浏览器上渲染 Alpha。
以下是一些进行转换的工具和网站:
免费 pngquant
Adobe Fireworks
和网站:http://www.8bitalpha.com/
另请参阅类似问题
8-bit PNGs with alpha transparency will only render alpha on newer webbrowsers.
Here are some tools and website that does the conversion:
free pngquant
Adobe Fireworks
and website: http://www.8bitalpha.com/
Also, see similar question
您描述的问题是 PNG 格式固有的。请参阅 维基百科 的条目,并注意颜色选项表中没有
的条目索引&阿尔法
。可以为 256 种颜色中的每一种添加 Alpha 值,但通常只有一个调色板条目将完全透明,其余部分将完全不透明。Paint Shop Pro 有几个选项用于混合或模拟调色板 PNG 中的部分透明度 - 我知道,因为我写了它。
The problem you describe is inherent in the PNG format. See the entry at Wikipedia and notice there's no entry in the color options table for
Indexed & alpha
. There's an ability to add an alpha value to each of the 256 colors, but typically only one palette entry will be made fully transparent and the rest will be fully opaque.Paint Shop Pro has a couple of options for blending or simulating partial transparency in a paletted PNG - I know because I wrote it.