Bitmap Image.Save(Path, ImageCodedInfo, EncoderParams) - XP Parameter not Valid Error

635 Views Asked by At

I have viewed a few of similar posts relating to my problem, but so far it 'appears' that my code does everything right and I cannot figure out why the image doesn't save.

To mention quickly, I'm personally running Windows7 Pro and when I save the Image here, it works perfectly fine and everything saves just as it should. My problem occurs when installing this application on WindowsXP Pro Service Pack 3.

My customers are not able to save the images and they receive a "Parameter not valid" error. Maybe there is some kind of *.dll needed to be registered? I have been on it for 2 days and any help would be AWESOME!

Here is the code

Save Button

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;
}

My Endcoder parameters are converted to (long) one of the solutions I found but already have the cast. Is it possible that ("image/tiff") is having a problem?

0

There are 0 best solutions below