1 /* 2 * Copyright (c) 2005, 2018, 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>TIFF Technical Note #2</td></tr> 60 * <tr> 61 * <td>ZLib</td> 62 * <td>"Deflate/Inflate" compression (see note following this table)</td> 63 * </tr> 64 * <tr> 65 * <td>PackBits</td> 66 * <td>Byte-oriented, run length compression</td> 67 * <td>TIFF 6.0 Specification, Section 9</td> 68 * </tr> 69 * <tr> 70 * <td>Deflate</td> 71 * <td>"Zip-in-TIFF" compression (see note following this table)</td> 72 * <td><a href="http://www.isi.edu/in-notes/rfc1950.txt"> 73 * ZLIB Compressed Data Format Specification</a>, 74 * <a href="http://www.isi.edu/in-notes/rfc1951.txt"> 75 * DEFLATE Compressed Data Format Specification</a></td> 76 * </tr> 77 * <tr> 78 * <td>Exif JPEG</td> 79 * <td>Exif-specific JPEG compression (see note following this table)</td> 80 * <td><a href="http://www.exif.org/Exif2-2.PDF">Exif 2.2 Specification</a> 81 * (PDF), section 4.5.5, "Basic Structure of Thumbnail Data"</td> 82 * </table> 83 * 84 * <p> 85 * Old-style JPEG compression as described in section 22 of the TIFF 6.0 86 * Specification is <i>not</i> supported. 87 * </p> 88 * 89 * <p> The CCITT compression types are applicable to bilevel (1-bit) 90 * images only. The JPEG compression type is applicable to byte 91 * grayscale (1-band) and RGB (3-band) images only.</p> 92 * 93 * <p> 94 * ZLib and Deflate compression are identical except for the value of the 95 * TIFF Compression field: for ZLib the Compression field has value 8 96 * whereas for Deflate it has value 32946 (0x80b2). In both cases each 97 * image segment (strip or tile) is written as a single complete zlib data 98 * stream. 99 * </p> 100 * 101 * <p> 102 * "Exif JPEG" is a compression type used when writing the contents of an 103 * APP1 Exif marker segment for inclusion in a JPEG native image metadata 104 * tree. The contents appended to the output when this compression type is 105 * used are a function of whether an empty or non-empty image is written. 106 * If the image is empty, then a TIFF IFD adhering to the specification of 107 * a compressed Exif primary IFD is appended. If the image is non-empty, 108 * then a complete IFD and image adhering to the specification of a 109 * compressed Exif thumbnail IFD and image are appended. Note that the 110 * data of the empty image may <i>not</i> later be appended using the pixel 111 * replacement capability of the TIFF writer. 112 * </p> 113 * 114 * <p> If ZLib/Deflate or JPEG compression is used, the compression quality 115 * may be set. For ZLib/Deflate the supplied floating point quality value is 116 * rescaled to the range <tt>[1, 9]</tt> and truncated to an integer 117 * to derive the Deflate compression level. For JPEG the floating point 118 * quality value is passed directly to the JPEG writer plug-in which 119 * interprets it in the usual way.</p> 120 * 121 * <p> The {@code canWriteTiles} and 122 * {@code canWriteCompressed} methods will return 123 * {@code true}; the {@code canOffsetTiles} and 124 * {@code canWriteProgressive} methods will return 125 * {@code false}.</p> 126 * 127 * <p> If tiles are being written, then each of their dimensions will be 128 * rounded to the nearest multiple of 16 per the TIFF specification. If 129 * JPEG-in-TIFF compression is being used, and tiles are being written 130 * each tile dimension will be rounded to the nearest multiple of 8 times 131 * the JPEG minimum coded unit (MCU) in that dimension. If JPEG-in-TIFF 132 * compression is being used and strips are being written, the number of 133 * rows per strip is rounded to a multiple of 8 times the maximum MCU over 134 * both dimensions.</p> 135 */ 136 public class TIFFImageWriteParam extends ImageWriteParam { 137 138 /** 139 * Constructs a {@code TIFFImageWriteParam} instance 140 * for a given {@code Locale}. 141 * 142 * @param locale the {@code Locale} for which messages 143 * should be localized. 144 */ 145 public TIFFImageWriteParam(Locale locale) { 146 super(locale); 147 this.canWriteCompressed = true; 148 this.canWriteTiles = true; 149 this.compressionTypes = TIFFImageWriter.TIFFCompressionTypes; 150 }; 151 }