1 /* 2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package com.sun.imageio.plugins.tiff; 26 27 import java.util.Locale; 28 import javax.imageio.ImageWriteParam; 29 30 /** 31 * A subclass of {@link ImageWriteParam ImageWriteParam} 32 * allowing control over the TIFF writing process. The set of innately 33 * supported compression types is listed in the following table: 34 * 35 * <table border=1> 36 * <caption><b>Supported Compression Types</b></caption> 37 * <tr><th>Compression Type</th> <th>Description</th> <th>Reference</th></tr> 38 * <tr> 39 * <td>CCITT RLE</td> 40 * <td>Modified Huffman compression</td> 41 * <td>TIFF 6.0 Specification, Section 10</td> 42 * </tr> 43 * <tr> 44 * <td>CCITT T.4</td> 45 * <td>CCITT T.4 bilevel encoding/Group 3 facsimile compression</td> 46 * <td>TIFF 6.0 Specification, Section 11</td> 47 * </tr> 48 * <tr> 49 * <td>CCITT T.6</td> 50 * <td>CCITT T.6 bilevel encoding/Group 4 facsimile compression</td> 51 * <td>TIFF 6.0 Specification, Section 11</td></tr> 52 * <tr> 53 * <td>LZW</td> 54 * <td>LZW compression</td> 55 * <td>TIFF 6.0 Specification, Section 13</td></tr> 56 * <tr> 57 * <td>JPEG</td> 58 * <td>"New" JPEG-in-TIFF compression</td> 59 * <td><a href="ftp://ftp.sgi.com/graphics/tiff/TTN2.draft.txt">TIFF 60 * Technical Note #2</a></td> 61 * </tr> 62 * <tr> 63 * <td>ZLib</td> 64 * <td>"Deflate/Inflate" compression (see note following this table)</td> 65 * </tr> 66 * <tr> 67 * <td>PackBits</td> 68 * <td>Byte-oriented, run length compression</td> 69 * <td>TIFF 6.0 Specification, Section 9</td> 70 * </tr> 71 * <tr> 72 * <td>Deflate</td> 73 * <td>"Zip-in-TIFF" compression (see note following this table)</td> 74 * <td><a href="http://www.isi.edu/in-notes/rfc1950.txt"> 75 * ZLIB Compressed Data Format Specification</a>, 76 * <a href="http://www.isi.edu/in-notes/rfc1951.txt"> 77 * DEFLATE Compressed Data Format Specification</a></td> 78 * </tr> 79 * <tr> 80 * <td>Exif JPEG</td> 81 * <td>Exif-specific JPEG compression (see note following this table)</td> 82 * <td><a href="http://www.exif.org/Exif2-2.PDF">Exif 2.2 Specification</a> 83 * (PDF), section 4.5.5, "Basic Structure of Thumbnail Data"</td> 84 * </table> 85 * 86 * <p> 87 * Old-style JPEG compression as described in section 22 of the TIFF 6.0 88 * Specification is <i>not</i> supported. 89 * </p> 90 * 91 * <p> The CCITT compression types are applicable to bilevel (1-bit) 92 * images only. The JPEG compression type is applicable to byte 93 * grayscale (1-band) and RGB (3-band) images only.</p> 94 * 95 * <p> 96 * ZLib and Deflate compression are identical except for the value of the 97 * TIFF Compression field: for ZLib the Compression field has value 8 98 * whereas for Deflate it has value 32946 (0x80b2). In both cases each 99 * image segment (strip or tile) is written as a single complete zlib data 100 * stream. 101 * </p> 102 * 103 * <p> 104 * "Exif JPEG" is a compression type used when writing the contents of an 105 * APP1 Exif marker segment for inclusion in a JPEG native image metadata 106 * tree. The contents appended to the output when this compression type is 107 * used are a function of whether an empty or non-empty image is written. 108 * If the image is empty, then a TIFF IFD adhering to the specification of 109 * a compressed Exif primary IFD is appended. If the image is non-empty, 110 * then a complete IFD and image adhering to the specification of a 111 * compressed Exif thumbnail IFD and image are appended. Note that the 112 * data of the empty image may <i>not</i> later be appended using the pixel 113 * replacement capability of the TIFF writer. 114 * </p> 115 * 116 * <p> If ZLib/Deflate or JPEG compression is used, the compression quality 117 * may be set. For ZLib/Deflate the supplied floating point quality value is 118 * rescaled to the range <tt>[1, 9]</tt> and truncated to an integer 119 * to derive the Deflate compression level. For JPEG the floating point 120 * quality value is passed directly to the JPEG writer plug-in which 121 * interprets it in the usual way.</p> 122 * 123 * <p> The {@code canWriteTiles} and 124 * {@code canWriteCompressed} methods will return 125 * {@code true}; the {@code canOffsetTiles} and 126 * {@code canWriteProgressive} methods will return 127 * {@code false}.</p> 128 * 129 * <p> If tiles are being written, then each of their dimensions will be 130 * rounded to the nearest multiple of 16 per the TIFF specification. If 131 * JPEG-in-TIFF compression is being used, and tiles are being written 132 * each tile dimension will be rounded to the nearest multiple of 8 times 133 * the JPEG minimum coded unit (MCU) in that dimension. If JPEG-in-TIFF 134 * compression is being used and strips are being written, the number of 135 * rows per strip is rounded to a multiple of 8 times the maximum MCU over 136 * both dimensions.</p> 137 */ 138 public class TIFFImageWriteParam extends ImageWriteParam { 139 140 /** 141 * Constructs a {@code TIFFImageWriteParam} instance 142 * for a given {@code Locale}. 143 * 144 * @param locale the {@code Locale} for which messages 145 * should be localized. 146 */ 147 public TIFFImageWriteParam(Locale locale) { 148 super(locale); 149 this.canWriteCompressed = true; 150 this.canWriteTiles = true; 151 this.compressionTypes = TIFFImageWriter.TIFFCompressionTypes; 152 }; 153 }