Skip to content

May I know how to use this library to convert to TIFF to android bitmap? #43

Answered by bosborn
Jimex asked this question in Q&A
Discussion options

You must be logged in to vote

That tiff file has predictor compression (in addition to LZW). Predictor decoding is currently not implemented.

Until implemented, here is a workaround that worked for your image:

TIFFImage tiffImage = TiffReader.readTiff(/* file, bytes, reader, or stream */);
FileDirectory fileDirectory = tiffImage.getFileDirectory();

Rasters rasters = fileDirectory.readRasters();
int width = rasters.getWidth();
int height = rasters.getHeight();

Bitmap bitmap = null;

switch(fileDirectory.getPhotometricInterpretation()){

    case TiffConstants.PHOTOMETRIC_INTERPRETATION_RGB:

        Integer predictor = fileDirectory.getIntegerEntryValue(FieldTagType.Predictor);
        boolean horizontalPredictor = p…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@Jimex
Comment options

@bosborn
Comment options

@Jimex
Comment options

Comment options

You must be logged in to vote
5 replies
@Jimex
Comment options

@bosborn
Comment options

@Jimex
Comment options

@bosborn
Comment options

@Jimex
Comment options

Answer selected by Jimex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants