Example usage for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_CCITT_GROUP_4

List of usage examples for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_CCITT_GROUP_4

Introduction

In this page you can find the example usage for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_CCITT_GROUP_4.

Prototype

int TIFF_COMPRESSION_CCITT_GROUP_4

To view the source code for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_CCITT_GROUP_4.

Click Source Link

Usage

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static void writeTiff(BufferedImage img, int compression, File file) throws IOException {
    if (img == null) {
        return;/* w  w w. j a  v  a  2s .c  o m*/
    }
    final ImageFormat format = ImageFormats.TIFF;
    final Map<String, Object> params = new HashMap<String, Object>();

    switch (compression) {
    case TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED:
    case TiffConstants.TIFF_COMPRESSION_CCITT_1D:
    case TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3:
    case TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_4:
    case TiffConstants.TIFF_COMPRESSION_LZW:
    case TiffConstants.TIFF_COMPRESSION_PACKBITS:
        //case TiffConstants.TIFF_COMPRESSION_JPEG:
        break;
    default:
        compression = TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED;
    }
    ;

    params.put(ImagingConstants.PARAM_KEY_COMPRESSION, new Integer(compression));

    try {
        Imaging.writeImage(img, file, format, params);
    } catch (ImageWriteException ex) {
        throw new IOException(ex);
    }
}