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
June 2010

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!



2010.06.22 12:21 "How to display 32 bits TIFF image", by Rafael Xiaoqun Gu

HI, I am a beginner to TIFF images.

I got 36 different kinds of TIFF images, 32 of them are 8 or 16 bits,
and 4 of them are 32 bits.  I need to using libtiff3.9.2 to read them
and send the buffer to a function which can display these images on
screen.

Now it's easy to display 8 or 16bits TIFF images by using
TIFFReadRGBAImage.  TIFFReadRGBAImage will return a buffer which include
TIFF image data, and send the buffer to the function, the function will
display it on screen.

Like: TIFFReadRGBAImage(m_tifInfo.pTiff, m_tifInfo.params.width,
m_tifInfo.params.height, pBuf, 0);

But it doesn't work for 32 bits TIFF.  I guess this function doesn't
support render a 32 bits images files.  So for 32 bits TIFF, first I
used TIFFReadScanline to read image data in TIFF, and using following
code to convert it from float format to s214 format (I am no very clear
about that, someone give me the code and let me have a try):

============= code start =============
The basic conversion from float to S214 is as follow:  short S214  =
Clamp( Rnd( fFloat * 16384.0f ), -32768.0f, 32767.0f)

Clamp can be implemented as an inlined function or as a macro

inline acfFloat32 Clamp(acfFloat32 val, acfFloat32 L, acfFloat32 H)
{
    if (val<=L) return L;
    if (val>=H) return H;

    return val;
}

Rnd can be implemented as follow:
inline acfSInt32 acplRnd(acfFloat32 a){return (((a)<0) ?
((acfSInt32)((a)-0.5)) : ((acfSInt32)((a)+0.5)));}
============= code start =============

I implemented the code in my project, and it did convert 32bits to
16bits, and there are something displayed in the screen, but it's not
the right result.

Do I need to convert the 16bits(converted from 32bits by coding above)
to RGBA, and then render again?  

Can you help me solve the issue?  Maybe little advice also makes sense,
like how to convert 32bits file to RGB or RGBA?

Thanks a lot.

Best regards,
Rafael Gu