KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > imageio > plugins > bmp > BMPImageWriteParam


1 /*
2  * @(#)BMPImageWriteParam.java 1.4 04/01/06
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.imageio.plugins.bmp;
9
10 import java.util.Locale JavaDoc;
11 import javax.imageio.ImageWriteParam JavaDoc;
12
13 import com.sun.imageio.plugins.bmp.BMPConstants;
14
15 /**
16  * A subclass of <code>ImageWriteParam</code> for encoding images in
17  * the BMP format.
18  *
19  * <p> This class allows for the specification of various parameters
20  * while writing a BMP format image file. By default, the data layout
21  * is bottom-up, such that the pixels are stored in bottom-up order,
22  * the first scanline being stored last.
23  *
24  * <p>The particular compression scheme to be used can be specified by using
25  * the <code>setCompressionType()</code> method with the appropriate type
26  * string. The compression scheme specified will be honored if and only if it
27  * is compatible with the type of image being written. If the specified
28  * compression scheme is not compatible with the type of image being written
29  * then the <code>IOException</code> will be thrown by the BMP image writer.
30  * If the compression type is not set explicitly then <code>getCompressionType()</code>
31  * will return <code>null</code>. In this case the BMP image writer will select
32  * a compression type that supports encoding of the given image without loss
33  * of the color resolution.
34  * <p>The compression type strings and the image type(s) each supports are
35  * listed in the following
36  * table:
37  *
38  * <p><table border=1>
39  * <caption><b>Compression Types</b></caption>
40  * <tr><th>Type String</th> <th>Description</th> <th>Image Types</th></tr>
41  * <tr><td>BI_RGB</td> <td>Uncompressed RLE</td> <td><= 8-bits/sample</td></tr>
42  * <tr><td>BI_RLE8</td> <td>8-bit Run Length Encoding</td> <td><= 8-bits/sample</td></tr>
43  * <tr><td>BI_RLE4</td> <td>4-bit Run Length Encoding</td> <td><= 4-bits/sample</td></tr>
44  * <tr><td>BI_BITFIELDS</td> <td>Packed data</td> <td> 16 or 32 bits/sample</td></tr>
45  * </table>
46  */

47 public class BMPImageWriteParam extends ImageWriteParam JavaDoc {
48
49     private boolean topDown = false;
50
51     /**
52      * Constructs a <code>BMPImageWriteParam</code> set to use a given
53      * <code>Locale</code> and with default values for all parameters.
54      *
55      * @param locale a <code>Locale</code> to be used to localize
56      * compression type names and quality descriptions, or
57      * <code>null</code>.
58      */

59     public BMPImageWriteParam(Locale JavaDoc locale) {
60         super(locale);
61
62         // Set compression types ("BI_RGB" denotes uncompressed).
63
compressionTypes = BMPConstants.compressionTypeNames;
64
65         // Set compression flag.
66
canWriteCompressed = true;
67         compressionMode = MODE_COPY_FROM_METADATA;
68         compressionType = compressionTypes[BMPConstants.BI_RGB];
69     }
70
71     /**
72      * Constructs an <code>BMPImageWriteParam</code> object with default
73      * values for all parameters and a <code>null</code> <code>Locale</code>.
74      */

75     public BMPImageWriteParam() {
76         this(null);
77     }
78
79     /**
80      * If set, the data will be written out in a top-down manner, the first
81      * scanline being written first.
82      *
83      * @param topDown whether the data are written in top-down order.
84      */

85     public void setTopDown(boolean topDown) {
86     this.topDown = topDown;
87     }
88
89     /**
90      * Returns the value of the <code>topDown</code> parameter.
91      * The default is <code>false</code>.
92      *
93      * @return whether the data are written in top-down order.
94      */

95     public boolean isTopDown() {
96     return topDown;
97     }
98 }
99
Popular Tags