locked
"A generic error occurred in GDI+." RRS feed

  • Question

  •  

    Hi everbody,

     

    I am lost! and I need some help. this is my code and I get  "A generic error occurred in GDI+." error and can't continue!

     

    Thanks

     

    private void saveImageExistingMultiplePage(Image[] bmp, Image origionalFile, string type, int PageNumber, string location)

    {

    try

    {

    //Now load the Codecs

    ImageCodecInfo codecInfo = getCodecForstring(type);

    Encoder saveEncoder;

    Encoder compressionEncoder;

    EncoderParameter SaveEncodeParam;

    EncoderParameter CompressionEncodeParam;

    EncoderParameters EncoderParams = new EncoderParameters(2);

    Bitmap pages;

    Bitmap NextPage;

     

    saveEncoder = Encoder.SaveFlag;

    compressionEncoder = Encoder.Compression;

    origionalFile.SelectActiveFrame(FrameDimension.Page, 0);

    pages = new Bitmap(origionalFile);

    pages = ConvertToBitonal(pages);

    // Save the first page (frame).

    SaveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);

    CompressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);

    EncoderParams.Param[0] = CompressionEncodeParam;

    EncoderParams.Param[1] = SaveEncodeParam;

    pages.Save(location, codecInfo, EncoderParams);

    //@"C:\src\WinScape\WinScape_v2.1\Connectors\debug_All\Temp\shreeTemp.tif"

    for (int i = 1; i < PageNumber; i++)

    {

    //myEncoderParameter = New EncoderParameter(myEncoder, Fix(EncoderValue.FrameDimensionPage))

    SaveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);

    CompressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);

    EncoderParams.Param[0] = CompressionEncodeParam;

    EncoderParams.Param[1] = SaveEncodeParam;

    origionalFile.SelectActiveFrame(FrameDimension.Page, i);

    NextPage = new Bitmap(origionalFile);

    NextPage = ConvertToBitonal(NextPage);

    pages.SaveAdd(NextPage, EncoderParams); // I get the error in this line!

    }

    for (int i = 0; i < bmp.Length; i++)

    {

    SaveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);

    CompressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);

    EncoderParams.Param[0] = CompressionEncodeParam;

    EncoderParams.Param[1] = SaveEncodeParam;

    bmpIdea = (Bitmap)ConvertToBitonal((Bitmap)bmpIdea);

    pages.SaveAdd(bmpIdea, EncoderParams);

    }

    SaveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.Flush);

    EncoderParams.Param[0] = SaveEncodeParam;

    pages.SaveAdd(EncoderParams);

    }

    catch (System.Exception ee)

    {

    throw ee;

    }

    Thursday, January 18, 2007 5:11 PM

Answers

All replies