Sign In  Sign Up Live-Chat

SelectActivePage error

Last post 06-10-2008, 8:01 AM by jimpoe. 5 replies.
Sort Posts: Previous Next
  •  06-03-2008, 12:57 PM 129880

    SelectActivePage error

    I get a 'Parameter not valid error' on the second iteration when calling SelectActivePage and I am using version 2.5.1.0.    If I use 2.3.0.0 of the dll, I don't get the error.

     

    private void RotateAllFrames(Image pImage, string pFileName)

    {

    // jpoe ht 398626 05/14/2008 - rotate landscape orientation to portrait orientation

    if (_TaskManager != null)

    {

    _TaskManager.ReportProgress("Rotating " + Path.GetFileName(pFileName),

    String.Empty,

    -1,

    false);

    Application.DoEvents();

    }

    string tempFileName = String.Empty;

    //get the codec for tiff files

    ImageCodecInfo info = null;

    foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())

    {

    if (ice.MimeType == "image/tiff")

    {

    info = ice;

    }

    }

    //use the save & compression encoder

    System.Drawing.Imaging.Encoder encSave = System.Drawing.Imaging.Encoder.SaveFlag;

    System.Drawing.Imaging.Encoder encComp = System.Drawing.Imaging.Encoder.Compression;

    EncoderParameters ep = new EncoderParameters(2);

    ep.Param[0] = new EncoderParameter(encSave, (long)EncoderValue.MultiFrame);

    ep.Param[1] = new EncoderParameter(encComp, (long)EncoderValue.CompressionCCITT4);

    Bitmap pages = null;

    Guid index = pImage.FrameDimensionsList[0];

    System.Drawing.Imaging.FrameDimension dimension;

    dimension = new System.Drawing.Imaging.FrameDimension(index);

    //Total frame numbers

    int totalFrame = pImage.GetFrameCount(dimension);

    try

    {

    for (int frame = 0; frame <= (totalFrame - 1); frame++)

    {

    pImage.SelectActiveFrame(dimension, frame);    //<------------------------------------

    if (frame == 0)

    {

    tempFileName = "~Rotating" + Path.GetFileName(pFileName);

    tempFileName = Path.Combine(Path.GetDirectoryName(pFileName), tempFileName);

    // copy the selected page

    Bitmap bm = new Bitmap(pImage, pImage.Width, pImage.Height);

    bm.SetResolution(pImage.HorizontalResolution, pImage.VerticalResolution);

    bm.RotateFlip(RotateFlipType.Rotate90FlipNone);

    // convert to a one bit per pixel image that is compatible with compression mode

    pages = Converter.ConvertToBitonal(bm);

    //save the file.

    pages.Save(tempFileName, info, ep);

    bm.Dispose();

    }

    else

    {

    //save the intermediate frames

    ep.Param[0] = new EncoderParameter(encSave, (long)EncoderValue.FrameDimensionPage);

    //copy the selected page

    Bitmap bm = new Bitmap(pImage, pImage.Width, pImage.Height);

    bm.SetResolution(pImage.HorizontalResolution, pImage.VerticalResolution);

    bm.RotateFlip(RotateFlipType.Rotate90FlipNone);

    // convert to a one bit per pixel image that is compatible with compression mode

    Bitmap bitonalbm = Converter.ConvertToBitonal(bm);

    pages.SaveAdd(bitonalbm, ep);

    //g.Dispose();

    bm.Dispose();

    bitonalbm.Dispose();

    }

    if (frame == totalFrame - 1)

    {

    //flush and close.

    ep.Param[0] = new EncoderParameter(encSave, (long)EncoderValue.Flush);

    pages.SaveAdd(ep);

    }

    }

     

    if (pages != null)

    {

    pages.Dispose();

    pImage.Dispose(); // closes original file

    if (tempFileName.Length > 0)

    {

    File.Delete(pFileName);

    File.Move(tempFileName, pFileName);

    }

    }

    }

    catch (Exception e)

    {

    mAppSupport.WriteError(e.ToString());

    mAppSupport.SendSupportNotification(e.ToString(), false);

    }

    }

     
  •  06-03-2008, 7:47 PM 129922 in reply to 129880

    Re: SelectActivePage error

    Hi kheckard,

       Could you please showing me the code you using Aspose.BarCode while the error occur? And please also try to save the tiff file before you calling SelectActivePage and attach the image here. And more, please send me the sample project if possible, that will help us to locate the problem as soon as possible.

       Thanks


    Dean Deng
    Lead Developer
    Aspose Guangzhou Team
    About Us
    Contact Us
     
  •  06-04-2008, 9:21 AM 130020 in reply to 129922

    Re: SelectActivePage error

    I keep getting a timeout error when I try to upload the zipped project.  Do you have an email address I could send it to?

     

    Jim

     
  •  06-04-2008, 7:56 PM 130105 in reply to 129922

    Re: SelectActivePage error

    Attachment: Present (inaccessible)
    I finally was able to upload from home. 

    Hope this helps.

    Jim
     
  •  06-09-2008, 11:04 PM 130676 in reply to 130105

    Re: SelectActivePage error

    Hi Jim,
     
       Please modified the code reading barcode as below:
     
           private void ReadImageInfo(Image pImage)
             {
                 // read all the barcodes and store results in the arraylist
                   using (Image tmpImg = (Image)pImage.Clone())
                   {
                         BarCodeReader barcodeReader = new BarCodeReader((Bitmap) tmpImg);
                         // jpoe ht 401230 05/30/2008 - this line reduces accuracy
                         barcodeReader.SymbologyType = Symbology.Code39Extended;

                         barcodeReader.Orientation = (Orientations) (-1); // all directions

                         BarCodeInfo[] infos;
                         infos = barcodeReader.Read();
                         foreach (BarCodeInfo info in infos)
                         {
                               mFileBarCodes.Add(info.CodeText);
                         }
                   }
             }

    Hi Jim,

       Please modified the code you reading the barcode as below:

     


    Dean Deng
    Lead Developer
    Aspose Guangzhou Team
    About Us
    Contact Us
     
  •  06-10-2008, 8:01 AM 130762 in reply to 130676

    Re: SelectActivePage error

    Thanks, that is working.

     

    Jim

     
View as RSS news feed in XML