在Delphi 2007中将具有透明度的位图保存为PNG [英] Save Bitmap with transparency to PNG in Delphi 2007

查看:112
本文介绍了在Delphi 2007中将具有透明度的位图保存为PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有透明度信息的Delphi位图(32Bit).我需要在保留透明度的同时将其转换并保存为PNG文件.

I have a Delphi bitmap (32Bit) that has transparency information. I need to convert and save it to a PNG file while preserving the transparency.

我目前拥有的工具是graphics32库,GR32_PNG(由Christian Budde设计)和PNGImage(由Gustavo daud设计).

The tools I currently have are the graphics32 Library, GR32_PNG (by Christian Budde), and PNGImage (by Gustavo daud).

做到这一点的最佳方法是什么?

What is the best way to do this?

我的位图中不仅只有一种颜色是透明的,还需要保留透明度不同的像素.

EDIT 1 : There is not just one color in my bitmap that's transparent but pixels with varying levels of transparency that needs to be preserved.

我通过将图像的背景设置为PNG来获得带有alpha信息的位图,而我只有空的alpha层.然后,我在上面写了抗锯齿的文本.然后,我保存位图.当使用gimp打开时,它会显示透明度,放大后您会看到抗锯齿的效果.

EDIT 2 : I am getting my bitmap with alpha information by setting the background of an image to a PNG I have with nothing but an empty alpha layer. Then I write anti-aliased text onto it. I then save the bitmap. When opened with gimp it show the transparency and upon zooming in you can see the effect of anti-aliasing.

推荐答案

我无法获得其他两个答案中的任何一个.他们可能会为他人工作,但这是我所做的.

I could not get either of the other two answer to work. They may work for others but here is what I did.

  1. 我创建了具有透明度的位图.
  2. 将其从Graphics 32库分配到TBitmap32.
  3. 将其分配给Christian Budde的GR32_PNG for Graphics32的TPortableNetworkGraphics32
  4. 调用了TPortableNetworkGraphics32.SaveToFile方法

这篇关于在Delphi 2007中将具有透明度的位图保存为PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆