| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2006.02.20 07:54 "TIFFReadScanline query", by <benarestham@gmail.com>I've some difficulty parsing the tiff image information into a raster array
to hold these values, processing the raster data then write the resulting
data into another tiff image. I've tried using the TIFFReadScanline function
to parse these data, however my image would not appear as the original. I'm
wondering where actually went wrong. Could anybody help advise?
My tiff file is extracted from a Kodak digital camera model DC290. The
default file information are as follows.
IMAGEWIDTH: 720
IMAGEHEIGHT: 480
SAMPLESPERPIXEL: 3
ROWSPERSTRIP: 3
BITSPERSAMPLE: 8
PLANARCONFIG: 1 (Chunky)
ORIENTATION: 1 (Top-Left)
PHOTOMETRIC: 2 (RGB)
====================Reading in the image information into pic_buffer================
int j, k, row_counter, offset;
tsize_t ScanlineSize = TIFFScanlineSize(tiffRead); //ScanlineSize = 2160 = 720*3
uint32* pic_buffer = (uint32*)_TIFFmalloc(sizeof(uint32) * imageWidth * imageHeight);
uint32* line_buffer = (uint32*)_TIFFmalloc(sizeof(uint32) * ScanlineSize);
k=0;
for (row_counter=0; row_counter<imageHeight; row_counter++)
{
TIFFReadScanline(tiffRead , line_buffer , row_counter);
for( j=0; j<ScanlineSize; j+=3 ) //reading RGB value from file and combining into pixel[k]
{
pic_buffer[k] = ( ((((uint32)line_buffer[j]) <<8<<8 )&0x00FF0000)
| ((((uint32)line_buffer[j+1]) <<8 )&0x0000FF00)
| (((uint32)line_buffer[j+2])&0x000000FF) );
k++;
}
}
====================Reading in the image information into pic_buffer================
=====================Writing the image information into output.tif=================
for (row_counter=0; row_counter<imageHeight; row_counter++)
{
k=0;
offset = row_counter*imageWidth;
for (j=0; j<imageWidth; j++)
{
line_buffer[k] = (uint32)((pic_buffer[j+offset]&0x00FF0000)>>8>>8); //Red content
line_buffer[k+1] = (uint32)((pic_buffer[j+offset]&0x0000FF00)>>8); //Green content
line_buffer[k+2] = (uint32)(pic_buffer[j+offset]&0x000000FF); //Blue content
k+=3;
}
TIFFWriteScanline(tiffWrite, line_buffer , row_counter, 0);
}
=====================Writing the image information into output.tif=================
Thanks to all whom have read and/or made a reply to this amateurish entry.
|
|||||||