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
July 2007

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

2007.07.01 10:30 "color quality = 16 bits problem.", by Roman Kazmin
2007.07.03 10:48 "Re: color quality = 16 bits problem.", by Joris Van Damme
2007.07.04 12:55 "Re: color quality = 16 bits problem.", by Roman Kazmin

2007.07.04 12:55 "Re: color quality = 16 bits problem.", by Roman Kazmin

* Joris <joris.at.lebbeke@skynet.be> [Tue, 3 Jul 2007 12:48:11 +0200]:
> Roman,
>
> Roman Kazmin wrote:
> > Could anybody help me with my question. Using libtiff library in my
> > own application I save picture on my PC as tiff file. All are Ok if 
my
> > display settings, color quality is 32 bits. When I have color 
quality
> > equals to 16 I receive picture with different colors( and I receive
> > two small images instead of one). What is it?
>
> It is not a LibTiff problem. Without looking at your code (and likely 
we
> don't want to if it's too large or messy), they're really is no way of
> telling what the problem might be.
>
> However, on Windows, results depending on display settings, usually
> point to
> the use of DDB (device dependent bitmap) where you ought to be using 
DIB
> (device independent bitmap) instead.
>
>
> Best regards,
>
> Joris Van Damme
> info@awaresystems.be
> http://www.awaresystems.be/
> Download your free TIFF tag viewer for windows here:
> http://www.awaresystems.be/imaging/tiff/astifftagviewer.html


May be you are correct. Send you small code. Could you see what is
uncorrect. This code work when color quality = 32

Somefunction(CBitmap* pBitMap)
{
                CSize size;
        size.cx = GetWidth();
        size.cy = GetHeight();
        int nSize = size.cx * size.cy;

        DWORD* lpvBits = new DWORD[nSize];
        if ( lpvBits == NULL )
                return 1;

        if ( pBitMap->GetBitmapBits(sizeof(DWORD)*nSize, lpvBits) == 0 )
        {
                delete [] lpvBits;
                return 1;
        }
        WriteHeader(size.cx, size.cy); // just first header!

        WriteImage(lpvBits, size.cx, size.cy);
}


WriteHeader(int nImageWidth, int nImageHeight)
{
        TIFFSetField(m_pTIFF, TIFFTAG_IMAGEWIDTH, nImageWidth);
        TIFFSetField(m_pTIFF, TIFFTAG_IMAGELENGTH, nImageHeight);
        TIFFSetField(m_pTIFF, TIFFTAG_BITSPERSAMPLE, 8);
        TIFFSetField(m_pTIFF, TIFFTAG_SAMPLESPERPIXEL, 4);

        uint32 rowsperstrip = TIFFDefaultStripSize(m_pTIFF, -1);
        //<REC> gives better compression

        TIFFSetField(m_pTIFF, TIFFTAG_ROWSPERSTRIP, rowsperstrip);

        // TIFFSetField(image, TIFFTAG_COMPRESSION,
COMPRESSION_CCITTFAX3);
        TIFFSetField(m_pTIFF, TIFFTAG_COMPRESSION,
COMPRESSION_PACKBITS);
        //TIFFSetField(m_pTIFF, TIFFTAG_COMPRESSION, COMPRESSION_NONE);


        // Start CCITTFAX3 setting

        uint32 group3options = GROUP3OPT_FILLBITS+GROUP3OPT_2DENCODING;
        //TIFFSetField(m_pTIFF, TIFFTAG_GROUP3OPTIONS, group3options);
        //TIFFSetField(m_pTIFF, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
        TIFFSetField(m_pTIFF, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
        TIFFSetField(m_pTIFF, TIFFTAG_ROWSPERSTRIP, -1L);


        // End CCITTFAX3 setting

        //if we comment following line then Tiff will not view in
Imaging
        //but view in DC
        TIFFSetField(m_pTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);

        TIFFSetField(m_pTIFF, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
        TIFFSetField(m_pTIFF, TIFFTAG_PLANARCONFIG,
PLANARCONFIG_CONTIG);

        TIFFSetField(m_pTIFF, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
        TIFFSetField(m_pTIFF, TIFFTAG_XRESOLUTION, 100.0);
        TIFFSetField(m_pTIFF, TIFFTAG_YRESOLUTION, 100.0);
}

WriteImage(DWORD* pBits, int nImageWidth, int nImageHeight)
{
        DWORD *bits = new DWORD[nImageWidth * nImageHeight];
        for(int i = 0, k = 0; i < nImageHeight; i++)
        {
                for(int j = 0; j < nImageWidth; j++)
                {
                        bits[k] = SWAP_RB(pBits[k]);
                        k++;
                }
        }

        for (int y = 0; y < nImageHeight; y++)
                if (TIFFWriteScanline(m_pTIFF, &bits[y * nImageWidth],
y)== -1 )
                        return FALSE;
}
--
Thank you in advance
          Roman Kazmin.