随着新位图改变图像 [英] As New Bitmap Alters Image

查看:64
本文介绍了随着新位图改变图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道为什么以下代码会改变图像。

I need to know why the following code alters the image.

Dim a = New Bitmap( _
My.Application.Info.DirectoryPath & "\a.png")
Dim b As New Bitmap(a)
b.Save("b.png", System.Drawing.Imaging.ImageFormat.Png)



请不要回复


And please don''t reply

Dim b = a



我需要知道为什么会产生颜色图像被改变(即白色变为254,其他颜色和alpha值改变)。我需要写这个,以便生成的图片的颜色与原始图片的颜色相匹配。


I need to know why the colors in the resulting image are altered (i.e. white becomes 254, and other colors and alpha values change). I need to write this so that the resulting picture''s colors match those of the original.

推荐答案





看看这里:

http://en.wikipedia.org/wiki/ Lossy_compression [ ^ ]

Hi,

Have a look here:
http://en.wikipedia.org/wiki/Lossy_compression[^]
来自维基百科页面的引用:
Quote from Wikipedia page:

在信息技术中,有损压缩是一种数据编码方法,通过丢弃(丢失)某些数据来压缩数据。

In information technology, "lossy" compression is a data encoding method that compresses data by discarding (losing) some of it.


您可以使用无损压缩,例如,在TIFF容器中,它可以支持许多不同的压缩算法,其中大多数是无损的。 PNG也支持无损压缩。请参阅:

http://en.wikipedia.org/wiki/Portable_Network_Graphics [< a href =http://en.wikipedia.org/wiki/Portable_Network_Graphicstarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Tagged_Image_File_Format [ ^ ],

http ://en.wikipedia.org/wiki/Lossless_data_compression [ ^ ]。



现在,.NET类不支持PNG压缩参数。相反,您可以考虑使用此库: http://optipng.sourceforge.net/ [ ^ ]。

不幸的是,这是一个C库。您可以通过P / Invoke或C ++ / CLI(混合模式)在.NET项目中使用它。

您可能希望搜索更多内容以期找到更好的东西。



所以,使用TIFF可能会更好,因为.NET FCL提供了一个TIFF支持类:

http://msdn.microsoft.com/en-us/library/system.windows。 media.imaging.tiffbitmapencoder%28v = vs.90%29.aspx [ ^ ](及更高版本的.NET)。



祝你好运,

-SA
You can use lossless compression, for example, in the TIFF container, which can support a number of different compression algorithms, most of them are lossless. PNG supports lossless compression as well. Please see:
http://en.wikipedia.org/wiki/Portable_Network_Graphics[^],
http://en.wikipedia.org/wiki/Tagged_Image_File_Format[^],
http://en.wikipedia.org/wiki/Lossless_data_compression[^].

Now, .NET classes do not support PNG compression parameters. Instead, you can consider using this library: http://optipng.sourceforge.net/[^].
Unfortunately, this is a C library. You can use it in your .NET projects via P/Invoke or C++/CLI (mixed mode).
You might want to search more in hope to find something better.

So, you might be better off with TIFF, as .NET FCL offers a class for TIFF support:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.tiffbitmapencoder%28v=vs.90%29.aspx[^] (and later versions of .NET).

Good luck,
—SA


这篇关于随着新位图改变图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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