GNU Classpath (0.95) | |
Frames | No Frames |
1: /* BMPImageWriteParam.java -- 2: Copyright (C) 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.imageio.plugins.bmp; 40: 41: import java.util.Locale; 42: 43: import javax.imageio.ImageWriteParam; 44: 45: /** 46: * A class to encode images in the BMP format. 47: * By default, the data layout is bottom-up, such that the pixels are stored in 48: * bottom-up order. 49: * 50: * The compression scheme can be specified by using setCompressionType() 51: * appropriate type string. The compression scheme specified will be honored 52: * if it is compatible with the type of image being written. If the 53: * compression scheme is not compatible with the type of image being written, 54: * then an IOException will be thrown by the BMP image writer. If the 55: * compression type is not set, then getCompressionType() will return null. 56: * In this case the BMP image writer will select a compression type that 57: * supports encoding of the given image without loss of the color resolution. 58: * 59: * The compression type strings and the image type each supports are: 60: * Uncompressed RLE: BI_RGB, image type: <= 8-bits/sample. 61: * 8-bit Run Length Encoding: BI_RLE8, image type: <= 8-bits/sample 62: * 4-bit Run Length Encoding: BI_RLE4, image type: <= 4-bits/sample 63: * Packed data: BI_BITFIELDS, image type: 16 or 32 bits/sample 64: * 65: * @author Lillian Angel (langel at redhat dot com) 66: */ 67: public class BMPImageWriteParam 68: extends ImageWriteParam 69: { 70: 71: /** 72: * This boolean is true if the data will be written in a topdown manner. 73: */ 74: private boolean topDown; 75: 76: /** 77: * Compression type strings. 78: */ 79: String rgb = "BI_RGB"; 80: String rle8 = "BI_RLE8"; 81: String rle4 = "BI_RLE4"; 82: String bitfields = "BI_BITFIELDS"; 83: 84: /** 85: * Constants to represent image types. 86: */ 87: static final int BI_RGB = 0; 88: static final int BI_RLE8 = 1; 89: static final int BI_RLE4 = 2; 90: static final int BI_BITFIELDS = 3; 91: 92: /** 93: * Constructs an <code>BMPImageWriteParam</code> object with default values 94: * and a <code>null Locale</code>. 95: */ 96: public BMPImageWriteParam() 97: { 98: this(null); 99: } 100: 101: /** 102: * Constructs a <code>BMPImageWriteParam</code> set to use a given 103: * <code>Locale</code> and with default values for all parameters. 104: * 105: * @param locale - a <code>Locale</code> to be used to localize compression 106: * type names and quality descriptions, or <code>null</code>. 107: */ 108: public BMPImageWriteParam(Locale locale) 109: { 110: super(locale); 111: topDown = false; 112: canWriteCompressed = true; 113: 114: compressionTypes = new String[4]; 115: compressionTypes[BI_RGB] = rgb; 116: compressionTypes[BI_RLE8] = rle8; 117: compressionTypes[BI_RLE4] = rle4; 118: compressionTypes[BI_BITFIELDS] = bitfields; 119: 120: compressionType = compressionTypes[BI_RGB]; 121: } 122: 123: /** 124: * If set, the data will be written out in a top-down manner, the first 125: * scanline being written first. 126: * 127: * @param topDown - whether the data are written in top-down order. 128: */ 129: public void setTopDown(boolean topDown) 130: { 131: this.topDown = topDown; 132: } 133: 134: /** 135: * Returns the value of the <code>topDown</code> parameter. The default is 136: * false. 137: * 138: * @return whether the data are written in top-down order. 139: */ 140: public boolean isTopDown() 141: { 142: return topDown; 143: } 144: }
GNU Classpath (0.95) |