C#Bitmap.Save transparancy不PNG保存 [英] c# Bitmap.Save transparancy doesn't save in png

查看:712
本文介绍了C#Bitmap.Save transparancy不PNG保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存有transparancy与transparancy一个PNG文件中的Bitmap类。
我有没有运气。

I'm trying to save a Bitmap class that has transparancy as a png file with transparancy. I'm having no luck.

这是我在做什么。

Bitmap ret = new Bitmap(bWidth, bHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

saveing​​

ret.Save(filename, ImageFormat.Png);

我也试过节省了FILESTREAM文件,并没有什么区别。

I also tried saving the file with a filestream, and that made no difference.

在图像是一个图片框transparancy存在,但是当我救我我只是得到一个黑色的背景。

When the image is in a Picture box the transparancy exists, but when I save i I just get a black background.

我真的不希望使用任何第三方code,他们发现了一个办法做到这一点,我想也。

I really don't want to use any 3rd party code, they found a way to do it, I'd like to also.

感谢。

推荐答案

我认为一个对话框的FilterIndex 0开始......但它实际上从1开始,所以我的图像用阿尔法transparancy被保存为照片与图像和GIF不支持Alpha透明度。所以,我的问题实际上是与该对话框。

I assumed that the FilterIndex of a dialog box started at 0...but it actually starts at 1, so my images were being saved as Gifs using alpha transparancy, and gif doesn't support alpha transparency. So my problem was actually with the dialog box.

这篇关于C#Bitmap.Save transparancy不PNG保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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