[gdal-dev] OpenJpegDataset IReadBlock question

Even Rouault even.rouault at mines-paris.org
Tue Apr 10 09:41:08 EDT 2012


>
> I am using a sample data file provided by openjpeg data folder named
> p1_04.j2k.  How is the data retrieved from opj_decode_tile_data() is being
> stored in the buffer?  To access pixel 0, is it just buffer[0] or is there
> another way?
> For some reason, my request for Tile (0,0) of length 128x128 returns an image
> that looks masked.  The image is mostly black and white with no depth of
> shading (i.e. missing information). 
> This image also uses 12 bits-per-pixel which I do not see where GDAL
> truncates the image data down to 8 bits-per-pixel.  Does GDAL return the raw
> 12 bits-per-pixel forcing the user to truncate the data properly for every
> pixel or is it handled by GDAL (If so, where)?

Depending on the precision information given by the JPEG2000 metadata, the
buffer will contain data of type 8 bit (GDT_Byte), 16 bits (GDT_Int16 or
GDT_UInt16) or 32 bits (GDT_Int32 or GDT_UInt32). For 12 bits per pixels, the
immediate upper type will be selected to store the data, thus GDT_Int16.

There's at least one regression test for the OpenJpeg driver that testes 16 bit
images.


More information about the gdal-dev mailing list