001/*002 * $RCSfile: BMPImageWriteParam.java,v $003 *004 * 005 * Copyright (c) 2005 Sun Microsystems, Inc. All  Rights Reserved.006 * 007 * Redistribution and use in source and binary forms, with or without008 * modification, are permitted provided that the following conditions009 * are met: 010 * 011 * - Redistribution of source code must retain the above copyright 012 *   notice, this  list of conditions and the following disclaimer.013 * 014 * - Redistribution in binary form must reproduce the above copyright015 *   notice, this list of conditions and the following disclaimer in 016 *   the documentation and/or other materials provided with the017 *   distribution.018 * 019 * Neither the name of Sun Microsystems, Inc. or the names of 020 * contributors may be used to endorse or promote products derived 021 * from this software without specific prior written permission.022 * 023 * This software is provided "AS IS," without a warranty of any 024 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 025 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 026 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY027 * EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL 028 * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 029 * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS030 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR 031 * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,032 * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND033 * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR034 * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE035 * POSSIBILITY OF SUCH DAMAGES. 036 * 037 * You acknowledge that this software is not designed or intended for 038 * use in the design, construction, operation or maintenance of any 039 * nuclear facility. 040 *041 * $Revision: 1.2 $042 * $Date: 2006/04/14 21:32:04 $043 * $State: Exp $044 */045package com.github.jaiimageio.plugins.bmp;046047import java.util.Locale;048049import javax.imageio.ImageWriteParam;050051import com.github.jaiimageio.impl.plugins.bmp.BMPConstants;052053/**054 * A subclass of <code>ImageWriteParam</code> for encoding images in055 * the BMP format.056 *057 * <p> This class allows for the specification of various parameters058 * while writing a BMP format image file.  By default, the data layout 059 * is bottom-up, such that the pixels are stored in bottom-up order, 060 * the first scanline being stored last.061 *062 * <p>The particular compression scheme to be used can be specified by using063 * the <code>setCompressionType()</code> method with the appropriate type064 * string.  The compression scheme specified will be honored if and only if it065 * is compatible with the type of image being written. If the specified 066 * compression scheme is not compatible with the type of image being written067 * then the <code>IOException</code> will be thrown by the BMP image writer.068 * If the compression type is not set explicitly then <code>getCompressionType()</code>069 * will return <code>null</code>. In this case the BMP image writer will select 070 * a compression type that supports encoding of the given image without loss071 * of the color resolution.072 * <p>The compression type strings and the image type(s) each supports are073 * listed in the following074 * table:075 *076 * <p><table border=1>077 * <caption><b>Compression Types</b></caption>078 * <tr><th>Type String</th> <th>Description</th>  <th>Image Types</th></tr>079 * <tr><td>BI_RGB</td>  <td>Uncompressed RLE</td> <td><= 8-bits/sample</td></tr>080 * <tr><td>BI_RLE8</td> <td>8-bit Run Length Encoding</td> <td><= 8-bits/sample</td></tr>081 * <tr><td>BI_RLE4</td> <td>4-bit Run Length Encoding</td> <td><= 4-bits/sample</td></tr>082 * <tr><td>BI_BITFIELDS</td> <td>Packed data</td> <td> 16 or 32 bits/sample</td></tr>083 * <tr><td>BI_JPEG</td> <td>JPEG encoded</td> <td>grayscale or RGB image</td></tr>084 * </table>085 *086 * <p> When <code>BI_BITFIELDS</code> is used, if the image encoded has a087 * <code>DirectColorModel</code>, the bit mask in the color model will be088 * written into the stream.  Otherwise, only 5-5-5 16-bit image or 8-8-8 089 * 32-bit images are supported.090 *091 */092public class BMPImageWriteParam extends ImageWriteParam {093094    // deprecated version constants095096    /** 097     * Constant for BMP version 2. 098     *099     * @deprecated100     */101    public static final int VERSION_2 = 0;102103    /** 104     * Constant for BMP version 3. 105     *106     * @deprecated107     */108    public static final int VERSION_3 = 1;109110    /** 111     * Constant for BMP version 4. 112     *113     * @deprecated114     */115    public static final int VERSION_4 = 2;116117    /** 118     * Constant for BMP version 5. 119     *120     * @deprecated121     */122    public static final int VERSION_5 = 3;123124    private boolean topDown = false;125126    /**127     * Constructs a <code>BMPImageWriteParam</code> set to use a given128     * <code>Locale</code> and with default values for all parameters.129     *130     * @param locale a <code>Locale</code> to be used to localize131     * compression type names and quality descriptions, or132     * <code>null</code>.133     */134    public BMPImageWriteParam(Locale locale) {135        super(locale);136137        // Set compression types ("BI_RGB" denotes uncompressed).138        compressionTypes = BMPConstants.compressionTypeNames;139140        // Set compression flag.141        canWriteCompressed = true;142        compressionMode = MODE_COPY_FROM_METADATA;143        compressionType = compressionTypes[BMPConstants.BI_RGB];144    }145146    /**147     * Constructs an <code>BMPImageWriteParam</code> object with default148     * values for all parameters and a <code>null</code> <code>Locale</code>.149     */150    public BMPImageWriteParam() {151        this(null);152    }153154    /**155     * Returns the BMP version to be used.  The default is156     * <code>VERSION_3</code>.157     *158     * @deprecated159     * @return the BMP version number.160     */161    public int getVersion() {162        return VERSION_3;163    }164165    /**166     * If set, the data will be written out in a top-down manner, the first167     * scanline being written first.168     *169     * Any compression other than <code>BI_RGB</code> or 170     * <code>BI_BITFIELDS</code> is incompatible with the data being 171     * written in top-down order. Setting the <code>topDown</code> argument172     * to <code>true</code> will be honored only when the compression 173     * type at the time of writing the image is one of the two mentioned174     * above. Otherwise, the <code>topDown</code> setting will be ignored.175     * 176     * @param topDown whether the data are written in top-down order.177     */178    public void setTopDown(boolean topDown) {179        this.topDown = topDown;180    }181182    /**183     * Returns the value of the <code>topDown</code> parameter.184     * The default is <code>false</code>.185     *186     * @return whether the data are written in top-down order.187     */188    public boolean isTopDown() {189        return topDown;190    }191192    // Override superclass implementation to add a new check that compression 193    // is not being set when image has been specified to be encoded in a top194    // down fashion195196    /**197     * Sets the compression type to one of the values indicated by198     * <code>getCompressionTypes</code>.  If a value of199     * <code>null</code> is passed in, any previous setting is200     * removed.201     *202     * <p>The method first invokes203     * {@link javax.imageio.ImageWriteParam.#setCompressionType(String) 204     * <code>setCompressionType()</code>}205     *  with the supplied value of <code>compressionType</code>. Next, 206     * if {@link #isTopDown()} returns <code>true</code> and the207     * value of <code>compressionType</code> is incompatible with top-down208     * order, {@link #setTopDown(boolean)} is invoked with parameter209     * <code>topDown</code> set to <code>false</code>. The image will210     * then be written in bottom-up order with the specified211     * <code>compressionType</code>.</p>212     *213     * @param compressionType one of the <code>String</code>s returned214     * by <code>getCompressionTypes</code>, or <code>null</code> to215     * remove any previous setting.216     *217     * @exception UnsupportedOperationException if the writer does not218     * support compression.219     * @exception IllegalStateException if the compression mode is not220     * <code>MODE_EXPLICIT</code>.221     * @exception UnsupportedOperationException if there are no222     * settable compression types.223     * @exception IllegalArgumentException if224     * <code>compressionType</code> is non-<code>null</code> but is not225     * one of the values returned by <code>getCompressionTypes</code>.226     *227     * @see #isTopDown228     * @see #setTopDown229     * @see #getCompressionTypes230     * @see #getCompressionType231     * @see #unsetCompression232     */233    public void setCompressionType(String compressionType) {234        super.setCompressionType(compressionType);235        if (!(compressionType.equals("BI_RGB")) &&236            !(compressionType.equals("BI_BITFIELDS")) && topDown == true) {237            topDown = false;238        }239    }240241}


NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14