简体   繁体   English

为什么此代码的输出图像比原始图像暗?

[英]Why would the output image from this code be darker than the original?

I'm a newbie to working with images in NET. 我是使用NET中图像的新手。 My goal is to add text and an icon to the starting image, then save the output. 我的目标是在起始图像中添加文本和图标,然后保存输出。

The result comes out a bit darker. 结果变得更暗。 Starting with a solid image (png-24) #788eb3 comes out #6d84ab. 从纯色图像(png-24)开始,#788eb3出现#6d84ab。 Tested to insure background/transparency is not the issue. 经过测试以确保背景/透明性不是问题。

I removed everything except the code to get the image, then save it, and the result is still darker. 我删除了除代码以外的所有内容以获取图像,然后将其保存,结果仍然更暗。 What direction should I go to make this work better? 我应该朝哪个方向改善这项工作?

System.Drawing.Image img = Bitmap.FromFile(@"c:\\oldfile.png", true);
img.Save(@"c:\\newfile.png", ImageFormat.Png);

The real issue turned out to be the browser! 真正的问题竟然是浏览器! IE7 and IE8 render #788eb3 in a png differently than the same color as a css background color. IE7和IE8在png中呈现的#788eb3与与CSS背景颜色相同的颜色不同。 IE9, Chrome and Firefox all look good. IE9,Chrome和Firefox看起来都不错。

My guess is that you have the color correction turned on. 我的猜测是您已启用颜色校正。 Try passing false instead of true to Bitmap.FromFile. 尝试将false而不是true传递给Bitmap.FromFile。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 裁剪后的输出图像大于原始尺寸 - The output image after cropping is larger than the original size 以下代码的输出:为什么返回雨天[1] =星期日而不是星期五? - Output of following code : Why would it return rainyday[1] = Sunday and not friday? 位图大于原始图像 - Bitmap larger than original image 为什么生成的带水印的图像比原始图像大得多? - Why's the generated watermarked image is much more bigger than the original image? 缩小宽度和高度后,为什么我的BMP图像比原始图像大? - Why my BMP image is bigger than the original after reducing its width and height? 为什么将图像保存在C#位图上的文件大小与原始文件不同? - Why does saving image on C# Bitmap give different file size than original? 为什么我的代码输出原始字符串值和转换后的字符串值,而不仅仅是转换后的字符串值? - Why is my code outputting the original string value and the converted string value rather than just the converted string value? Imagesharp 将我的图像调整为比原始图像大 - Imagesharp resizes my image larger than the original 为什么在我的 C# 代码中 MD5 会比 SHA256 慢? - Why would MD5 be slower than SHA256 in my C# code? 窗口背景颜色:显得比指定的更暗? - Window background color: appears darker than specified?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM