ngageoint / tiff-java

Tagged Image File Format Java Library
https://ngageoint.github.io/tiff-java
MIT License
72 stars 33 forks source link

Extracting 16 bit integer pixels from rasters object. #30

Closed mlaprise closed 3 years ago

mlaprise commented 3 years ago

First of all, thx for the library. It's surprising hard to get good image library on Java/Android.

The documentation is a little bit short on details on how to access the pixels from a loaded image. When using the following snippet of code I can only get a bytes buffer using either rasters.getInterleaveValues() or rasters.getSamplesValues().

TIFFImage tiffImage = TiffReader.readTiff(input); List<FileDirectory> directories = tiffImage.getFileDirectories(); FileDirectory directory = directories.get(0); Rasters rasters = directory.readRasters();

Does it mean we need to convert this buffer into the proper integer array ourself ? Is there any other ways builtin into the library ? Would it be possible to point me to an example ? Thx !

bosborn commented 3 years ago

We are using it in our GeoPackage libraries to read/write GeoPackage Tiled Gridded Coverage Data.

Tiles are encoded as a single-band image using one 32-bit floating point component per pixel.

Example Source:

The Rasters Javadoc: https://ngageoint.github.io/tiff-java/docs/api/mil/nga/tiff/Rasters.html

mlaprise commented 3 years ago

Thanks for examples. I'll take a look.