Reputation: 11
I have a VB6 application (using IMGSCAN and IMGEDIT conrols) to scan images from HP scanner through TWAIN which generates multipage tiff with old jpeg compression. Now When I access the new Kodak scanner i2600 through TWAIN from same VB6 application it hangs.
So now Im trying write an executable which will just scan and create a multi paged Tiff file which can be accessed in my VB6 application (through IMGEDIT conrol) for viewing.
I tried to create multipage tiff file with old JPEG compression using the C# code found on below post:
I used compression as 6, to achieve old JPEG compression. IFD:
{254, 4, 1, 0}, // NewSubfileType
{256, 4, 1, width}, // ImageWidth
{257, 4, 1, length}, // ImageLength
{258, 3, 3, offset}, // BitsPerSample
{259, 3, 1, 6}, // Compression (Old JPEG)
{262, 3, 1, 6}, //PhotometricInterpretation (YCbCr)
{273, 4, 1, offset + 22}, // StripOffsets (offset IFH + entries + values of BitsPerSample & YResolution & XResolution)
{277, 3, 1, 3}, // SamplesPerPixel
{278, 4, 1, length}, // RowsPerStrip
{279, 4, 1, (uint)jpegs[i].LongLength}, // StripByteCounts
{282, 5, 1, offset + 6}, // XResolution (offset IFH + entries + values of BitsPerSample)
{283, 5, 1, offset + 14}, // YResolution (offset IFH + entries + values of BitsPerSample & YResolution)
{284, 3, 1, 1}, // PlanarConfiguration (chunky)
{296, 3, 1, 2} // ResolutionUnit
I successfully created the multi page TIFF file. But the problem is, IMGEDIT control (in VB6) is not display this images properly. All the images are distorted.
So I analysed IFD's of the old tiff file (created using vb6 application) with the new file (created using c# with above settings).
Old Tiff File
SUBFILETYPE 0
IMAGEWIDTH 826
IMAGELENGTH 1169
BITSPERSAMPLE 8
COMPRESSION OJPEG
PHOTOMETRIC YCBCR
FILLORDER MSB2LSB
STRIPOFFSETS System.UInt32[]
ORIENTATION TOPLEFT
SAMPLESPERPIXEL 3
ROWSPERSTRIP 8
STRIPBYTECOUNTS System.UInt32[]
XRESOLUTION 100
YRESOLUTION 100
PLANARCONFIG CONTIG
RESOLUTIONUNIT INCH
SOFTWARE System.Byte[]
TILEOFFSETS System.UInt32[]
TILEBYTECOUNTS System.UInt32[]
JPEGPROC 1
JPEGIFOFFSET 932
JPEGIFBYTECOUNT 601
JPEGRESTARTINTERVAL 0
JPEGQTABLES 3
JPEGDCTABLES 3
JPEGACTABLES 3
YCBCRSUBSAMPLING 2
New Tiff File:
SUBFILETYPE 0
IMAGEWIDTH 830
IMAGELENGTH 1172
BITSPERSAMPLE 8
COMPRESSION OJPEG
PHOTOMETRIC YCBCR
**< FILLORDER field missing when comparing above>**
STRIPOFFSETS System.UInt32[]
< ORIENTATION field missing when comparing above>
SAMPLESPERPIXEL 3
ROWSPERSTRIP 1172
STRIPBYTECOUNTS System.UInt32[]
XRESOLUTION 100
YRESOLUTION 100
PLANARCONFIG CONTIG
RESOLUTIONUNIT INCH
< SOFTWARE field missing when comparing above>
TILEOFFSETS System.UInt32[]
TILEBYTECOUNTS System.UInt32[]
< JPEGPROC field missing when comparing above>
< JPEGIFOFFSET field missing when comparing above>
< JPEGIFBYTECOUNT field missing when comparing above>
< JPEGRESTARTINTERVAL field missing when comparing above>
< JPEGQTABLES field missing when comparing above>
< JPEGDCTABLES field missing when comparing above>
< JPEGACTABLES field missing when comparing above>
YCBCRSUBSAMPLING 2
IFD's like JPEGPROC, JPEGIFOFFSET, JPEGIFBYTECOUNT, JPEGRESTARTINTERVAL, JPEGQTABLES, JPEGDCTABLES, JPEGACTABLES were not available in new file. I guess this might be the reason for IMGEDIT control not displaying image properly. Is anyway to set these properties while we generate the TIFF file ?
Upvotes: 1
Views: 1414
Reputation: 14236
Most probably you create your TIFF improperly.
Re-check IMAGEWIDTH
, SAMPLESPERPIXEL
and BITSPERSAMPLE
values. Some of them might be wrong and that is why you get distorted image.
You don't get JPEG***
tags in your output image because you can not create OldJPEG-encoded images with libtiff (there is simply no OldJpeg encoder, only decoder is present). And you you shouldn't create such images because OldJPEG is deprecated long long long long long time ago.
Upvotes: 0