所以我遇到了一个相当奇怪的情况。
我正在使用以下内容保存PNG(无损)图像,
public static void SaveJpeg(string path, Image image, int quality)
{
if ((quality < 0) || (quality > 100))
{
string error = string.Format("Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.", quality);
throw new ArgumentOutOfRangeException(error);
}
EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
ImageCodecInfo imgCodec = GetEncoderInfo("image/png");
EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam;
image.Save(path, imgCodec, encoderParams);
}
public static ImageCodecInfo GetEncoderInfo(string mimeType)
{
string lookupKey = mimeType.ToLower();
ImageCodecInfo foundCodec = null;
if (Encoders.ContainsKey(lookupKey))
{
foundCodec = Encoders[lookupKey];
}
return foundCodec;
}
此代码在XP中运行良好,图像保存无损,当我放大时,我看不到任何像素化,但是当在Windows7机器上运行相同的编译应用程序时,保存的图像看起来像素化。
这是由于我保存图像的方式,还是因为Windows 7中的图像保存功能/编码而改变的东西?