我已经查看了一些与我的问题相关的类似帖子,但到目前为止,“似乎”我的代码做的一切都是正确的,我无法弄清楚为什么图像没有保存。
快速提一下,我个人运行的是 Windows7 Pro,当我在这里保存图像时,它工作得非常好,一切都按原样保存。在 WindowsXP Pro Service Pack 3 上安装此应用程序时出现我的问题。
我的客户无法保存图像,并且收到“参数无效”错误。也许需要注册某种 *.dll ?我已经用了 2 天了,任何帮助都会很棒!
这是代码
保存按钮
foreach (Image img in list)
{
ImageCodecInfo myImageCodecInfo;
System.Drawing.Imaging.Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;
myImageCodecInfo = GetEncoderInfo("image/tiff");
myEncoder = System.Drawing.Imaging.Encoder.Compression;
myEncoderParameters = new EncoderParameters(1);
myEncoderParameter = new EncoderParameter(myEncoder, (long)EncoderValue.CompressionCCITT4);
myEncoderParameters.Param[0] = myEncoderParameter;
Bitmap image;
image = new Bitmap(img);
image = image.Clone(new Rectangle(0, 0, image.Width, image.Height), PixelFormat.Format1bppIndexed);
image.SetResolution(300, 300);
// Manipulate what the Image Name is supposed to be here :
string _temp = "0000000000";
_temp += i;
_temp = _temp.Substring(_temp.Length - 4, 4);
// Save the Images to Year Folder
try
{
image.Save(string.Format("\\" + "\\" + _ServerName + "\\DeedImages\\" + _YearDirectory + "\\" + _DocNbr + "-" + _temp + ".tif"), myImageCodecInfo, myEncoderParameters);
//sImage.Save(string.Format("\\" + "\\" + _ServerName + "\\DeedImages\\" + _YearDirectory + "\\" + _DocNbr + "-" + _temp + ".tif"));
result = _objRoutines.SaveAs_Database_Image(_DocNbr, i, DateTime.Now.Year.ToString() + "\\" + _DocNbr + "-" + _temp + ".tif");
if (result != "Success")
{
MessageBox.Show(result + "\nPlease contact your software vendor!", "Internal Error", MessageBoxButtons.OK);
return;
}
i++;
image.Dispose();
}
catch (Exception ex) {
MessageBox.Show(ex.Message + "\nPlease contact your software vendor!", "Uknown1 Error", MessageBoxButtons.OK);
return;
}
i += 1;
}
我的 Endcoder 参数被转换为(长)我找到但已经有演员表的解决方案之一。("image/tiff") 有没有可能有问题?