1 18 package org.apache.batik.ext.awt.image.codec.tiff; 19 20 import java.util.Iterator ; 21 import java.util.zip.Deflater ; 22 23 import org.apache.batik.ext.awt.image.codec.ImageEncodeParam; 24 25 import com.sun.image.codec.jpeg.JPEGEncodeParam; 26 27 45 public class TIFFEncodeParam implements ImageEncodeParam { 46 47 48 public static final int COMPRESSION_NONE = 1; 49 50 54 public static final int COMPRESSION_GROUP3_1D = 2; 55 56 60 public static final int COMPRESSION_GROUP3_2D = 3; 61 62 66 public static final int COMPRESSION_GROUP4 = 4; 67 68 72 public static final int COMPRESSION_LZW = 5; 73 74 80 public static final int COMPRESSION_JPEG_BROKEN = 6; 81 82 86 public static final int COMPRESSION_JPEG_TTN2 = 7; 87 88 89 public static final int COMPRESSION_PACKBITS = 32773; 90 91 95 public static final int COMPRESSION_DEFLATE = 32946; 96 97 private int compression = COMPRESSION_NONE; 98 99 private boolean writeTiled = false; 100 private int tileWidth; 101 private int tileHeight; 102 103 private Iterator extraImages; 104 105 private TIFFField[] extraFields; 106 107 private boolean convertJPEGRGBToYCbCr = true; 108 private JPEGEncodeParam jpegEncodeParam = null; 109 110 private int deflateLevel = Deflater.DEFAULT_COMPRESSION; 111 112 116 public TIFFEncodeParam() {} 117 118 121 public int getCompression() { 122 return compression; 123 } 124 125 142 public void setCompression(int compression) { 143 144 switch(compression) { 145 case COMPRESSION_NONE: 146 case COMPRESSION_PACKBITS: 147 case COMPRESSION_JPEG_TTN2: 148 case COMPRESSION_DEFLATE: 149 break; 151 default: 152 throw new Error ("TIFFEncodeParam0"); 153 } 154 155 this.compression = compression; 156 } 157 158 161 public boolean getWriteTiled() { 162 return writeTiled; 163 } 164 165 172 public void setWriteTiled(boolean writeTiled) { 173 this.writeTiled = writeTiled; 174 } 175 176 196 public void setTileSize(int tileWidth, int tileHeight) { 197 this.tileWidth = tileWidth; 198 this.tileHeight = tileHeight; 199 } 200 201 204 public int getTileWidth() { 205 return tileWidth; 206 } 207 208 211 public int getTileHeight() { 212 return tileHeight; 213 } 214 215 232 public synchronized void setExtraImages(Iterator extraImages) { 233 this.extraImages = extraImages; 234 } 235 236 241 public synchronized Iterator getExtraImages() { 242 return extraImages; 243 } 244 245 252 public void setDeflateLevel(int deflateLevel) { 253 if(deflateLevel < 1 && deflateLevel > 9 && 254 deflateLevel != Deflater.DEFAULT_COMPRESSION) { 255 throw new Error ("TIFFEncodeParam1"); 256 } 257 258 this.deflateLevel = deflateLevel; 259 } 260 261 264 public int getDeflateLevel() { 265 return deflateLevel; 266 } 267 268 273 public void setJPEGCompressRGBToYCbCr(boolean convertJPEGRGBToYCbCr) { 274 this.convertJPEGRGBToYCbCr = convertJPEGRGBToYCbCr; 275 } 276 277 280 public boolean getJPEGCompressRGBToYCbCr() { 281 return convertJPEGRGBToYCbCr; 282 } 283 284 304 public void setJPEGEncodeParam(JPEGEncodeParam jpegEncodeParam) { 305 if(jpegEncodeParam != null) { 306 jpegEncodeParam = (JPEGEncodeParam)jpegEncodeParam.clone(); 307 jpegEncodeParam.setTableInfoValid(false); 308 jpegEncodeParam.setImageInfoValid(true); 309 } 310 this.jpegEncodeParam = jpegEncodeParam; 311 } 312 313 316 public JPEGEncodeParam getJPEGEncodeParam() { 317 return jpegEncodeParam; 318 } 319 320 330 public void setExtraFields(TIFFField[] extraFields) { 331 this.extraFields = extraFields; 332 } 333 334 337 public TIFFField[] getExtraFields() { 338 return extraFields; 339 } 340 } 341 | Popular Tags |