AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
February 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.02.20 07:54 "TIFFReadScanline query", by <benarestham@gmail.com>
2006.02.20 21:20 "Re: TIFFReadScanline query", by Chris Cox
2006.02.21 03:50 "Re: TIFFReadScanline query", by <benarestham@gmail.com>
2006.02.21 05:39 "Re: TIFFReadScanline query", by Charles Auer
2006.02.21 05:54 "Re: TIFFReadScanline query", by Joris Van Damme
2006.02.22 12:45 "Re: TIFFReadScanline query", by <benarestham@gmail.com>

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