0

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?

User 12345678
  • 7,714
  • 2
  • 28
  • 46
  • I'd go with TIFF being the issue. All encodings for TIFF aren't supported on earlier versions of Windows. You might have to play around with the encoder info flags. – Simon Whitehead Aug 10 '13 at 14:52
  • XP has an older version of GDI+, v1.00 instead of v1.10. I'd assume it doesn't yet support that encoder parameter. Otherwise always an issue with TIFF, it means Thousands of Incompatible File Formats. Updating is not an option. I mean GDI+, your customer of course always can. About time. – Hans Passant Aug 10 '13 at 17:41
  • No idea how you managed to convert a bitmap to 1bpp in gdi+ 1.0(xp) like this. Could you please try to use the converter in [this project](http://www.codeproject.com/Articles/16904/Save-images-into-a-multi-page-TIFF-file-or-add-ima) (ConvertToBitonal) - i ran your code using it and it worked just fine on xp and .net framework 2.0 – UIlrvnd Aug 10 '13 at 20:12

0 Answers0