2

My C# application receives image files from KOFAX VRS TWAIN driver in TWSX_FILE mode, but neither my own .NET based application nor Windows default image viewer can open these files. However, Adobe Photoshop can open them without any problem. I tried FreeImage library and although it detects their dimensions correctly it renders black images. It seems that KOFAX has some kind of its own bitmap format which its header is different from normal bmp files: http://www.fileformat.info/mirror/egff/ch03_03.htm I have uploaded one of these files here: http://www.box.net/shared/aby42aagz4 I wanted to know how can I open these images in my applications, anybody knows any lightweight open source/free library or C++/C# code snippet, supporting this image format?

hamid reza
  • 416
  • 6
  • 14
  • Are you sure they are actually bitmap files? Kofax VRS typically accepts 8-bit greyscale images from a scanner and then outputs bitonal TIFF images. – Brian Dec 29 '10 at 01:56
  • @Brian: Sorry I haven't seen your comment until now. I have uploaded one of these files as I mentioned in my question, it seems to be a BMP file, it begins with "BM" if you open it with a text editor, and Photosop opens it as an 8-bit RGB color image not an Indexed Color image and it actually has more than 2 colors. – hamid reza Feb 07 '11 at 16:32

1 Answers1

2

You've basically answered your own question: The file is neither a Windows bitmap file nor is it in the documented Kofax Raster Format.

As you pointed out, the first two bytes are 'BM', which would indicate the file is purporting to be a Windows bitmap. However, if that were truly the case the next four bytes would contain the file size. In your sample file, the next four bytes contain a value much bigger than the actual file size so it can't be correctly interpreted as a Windows bitmap file.

As the fileformat.info site you linked to states, if the file was truly in Kofax Raster Format, it would start with the bytes '68464B2Eh'. Thus, your file isn't in Kofax Raster Format either. In fact, I tried opening it with Kofax's VCDemo software and got the following error: "Error 20204 - Internal invalid state"

Thus, Kofax's own software thinks the file is corrupt.

The fact that Photoshop can open it and display something doesn't necessarily mean it's a valid image file format. Image processing software packages will often simply try to guess at interpreting the raw bytes of the file. Sometimes they get lucky, sometimes not.

Trying to find something that can read the files assumes that the file is in a standard format, which it isn't. Thus, I wouldn't search for something that could read the file but instead search for why the VRS/TWAIN configuration you are using is producing a non-standard format.

Brian
  • 361
  • 2
  • 7