Community

A generic error occurred in GDI+ Answered

Dear Sir/Madam,

I am having an error in my code if i try to get an image as Black & White colored. My file is a one page (tif) file in format : "Tiff Black White Ccitt Group4" Thanks in advance. Here is my code :

 private static void convertToBlackWhite(FRDocument frDoc)
        {
          int pagesCount = frDoc.Pages.Count;
          Bitmap[] blackWhiteImg = new Bitmap[pagesCount];
          for (int i = 0; i < pagesCount; i++)
          {
            FRPage page = frDoc.Pages;
            ImageDocument imageDoc = page.ImageDocument;
            FREngine.Image image = imageDoc.BlackWhiteImage;
            IntPtr hBitmap = (IntPtr)image.GetPicture(null, 0);
            blackWhiteImg = System.Drawing.Image.FromHbitmap(hBitmap);//this line throws error
            blackWhiteImg.SetResolution(image.XResolution, image.YResolution);
            Gdi32Helper.DeleteObject(hBitmap);
          }
        //other codes..
    }
0

Comments

2 comments

  • Avatar
    hakanaktan

    I have found something in document : FREngine 10 UserGuide In page 1027 in table i see the text below. It is about "IImage::GetPicture"

    A remark has been added. These methods do not work if the Engine object is created using the OutprocLoader object.

    I am using OutProcLoader. Is there an alternative way of GetPicture method for OutProcLoader?

    0
  • Avatar
    Diana Khammatova

    Hi Hakan

    As you rightly pointed out according to the help method IImage::GetPicture does not work if the Engine object is created using the OutprocLoader object. The only way to get an image in FineReader Engine 10.5 is to use IImage::WriteToFile method.

    1

Please sign in to leave a comment.