[Gdal-dev] 1 and 4 bits image
Frank Warmerdam
warmerdam at pobox.com
Wed Apr 30 11:07:51 EDT 2003
Sylvain Rioux wrote:
> Hi,
>
> I am having trouble with 16-colors bitmaps (4 bits) and i was wondering
> at how GDAL manages this format. I get a bitmap where the pixels values
> seem to have been slighly shifted and the result is far from what i
> expected. This problem does also occur with monochrome bitmaps. So far i
> successfully read 256 colors bitmaps and, gifs, jpegs, and the other
> raster formats supported by GDAL.It seems clear to me that the fact that
> the pixels are defined on 1 or 4 bits rather than a byte causes this
> misalignment.
>
> I'm using Windows and my current procedure is to use a BITMAPINFO
> structure, and fill the pixel values buffer with
> GDALDataset::RasterIO(...). This works for all the raster images i
> tried. So, to get to the point, i want to know how RasterIO actually
> fills the buffer when reading 4 bits bitmap.
Sylvain,
Currently it looks as though GDAL will translate TIFF files with less than
8 bits per pixel, and more than 1 via the libtiff RGBA interface. That is
expand it to four 8bit bands. There is a special case for 1 bit data which
just expands it to 8bit data. I don't find alot of 2, or 4 bit TIFF files,
but if necessary the tiff driver could be modified to expand 2 and 4 bit
files to 8 bit, like the 1 bit case.
Note that 1 bit files are expanded to an 8bit band that happens to only
have the values 0 and 1.
Best reards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list