[Gdal-dev] Bug in BMP driver?

Winkler, Roland RWinkler at DEFiNiENS.com
Tue Nov 4 08:39:44 EST 2003


Hi,

I have problems reading a 32 bit RGB Windows Bitmap (type BMPC_RGB). I
changed the ::IReadblock for 32 bit bitmaps and it worked afterwards:

CPLErr BMPRasterBand::IReadBlock::IReadBlock()
{
...
old:
    
    if ( poGDS->sInfoHeader.iBitCount == 24 ||
         poGDS->sInfoHeader.iBitCount == 32 )
    {
        for ( i = 0, j = 0; i < nBlockXSize; i++ )
        {
            // Colour triplets in BMP file organized in reverse order:
            // blue, green, red
            ((GByte *) pImage)[i] = pabyScan[j + iBytesPerPixel - nBand];
            j += iBytesPerPixel;
        }
    }
new:
    if ( poGDS->sInfoHeader.iBitCount == 24 )
    	.. like before
    else if ( poGDS->sInfoHeader.iBitCount == 32 )
    {
        for ( i = 0, j = 0; i < nBlockXSize; i++ )
        {
            ((GByte *) pImage)[i] = pabyScan[j + iBytesPerPixel - nBand -
1];
            j += iBytesPerPixel;
        }
    }
...
}
the reason for the -1 in the 32 bit case:
in 24 bit case for each pixel the array pabyScan looks like [BGR] pImage is
assigned [RGB]
the implementation for 32 implies that the order of pabyScan is [ABGR], but
I think it should be [BGRA].
I'm not quite sure about it, because I have only one 32 bit bitmap and I
couldn't produce another example.

Has anybody else problems with 32 bit .bmp's, or is my .bmp corrupt?

Thanks
Roland

_________________________________
 
Roland Winkler,
Software Development
 
Definiens AG
Trappentreustrasse 1
D-80339 Munich
 
Fon: +49 (0)89 - 231180 - 56
Fax: +49 (0)89 - 231180 - 90
 
mailto:rwinkler at definiens.com <mailto:rwinkler at definiens.com> 
http://www.definiens.com <http://www.definiens.com/> 
_________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20031104/33bc28bc/attachment.html


More information about the Gdal-dev mailing list