A generic error occurred in GDI+

  • 241 Views
  • Last Post 21 December 2016
  • Topic Is Solved
hakanaktan posted this 21 December 2016

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

Order By: Standard | Newest | Votes
hakanaktan posted this 21 December 2016

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?

Diana Khammatova posted this 23 December 2016

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.

  • Liked by
  • hakanaktan
Close