0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.imageio.plugins.bmp;
0N/A
0N/Aimport java.util.Locale;
0N/Aimport javax.imageio.ImageWriteParam;
0N/A
0N/Aimport com.sun.imageio.plugins.bmp.BMPConstants;
0N/A
0N/A/**
0N/A * A subclass of <code>ImageWriteParam</code> for encoding images in
0N/A * the BMP format.
0N/A *
0N/A * <p> This class allows for the specification of various parameters
0N/A * while writing a BMP format image file. By default, the data layout
0N/A * is bottom-up, such that the pixels are stored in bottom-up order,
0N/A * the first scanline being stored last.
0N/A *
0N/A * <p>The particular compression scheme to be used can be specified by using
0N/A * the <code>setCompressionType()</code> method with the appropriate type
0N/A * string. The compression scheme specified will be honored if and only if it
0N/A * is compatible with the type of image being written. If the specified
0N/A * compression scheme is not compatible with the type of image being written
0N/A * then the <code>IOException</code> will be thrown by the BMP image writer.
0N/A * If the compression type is not set explicitly then <code>getCompressionType()</code>
0N/A * will return <code>null</code>. In this case the BMP image writer will select
0N/A * a compression type that supports encoding of the given image without loss
0N/A * of the color resolution.
0N/A * <p>The compression type strings and the image type(s) each supports are
0N/A * listed in the following
0N/A * table:
0N/A *
0N/A * <p><table border=1>
0N/A * <caption><b>Compression Types</b></caption>
0N/A * <tr><th>Type String</th> <th>Description</th> <th>Image Types</th></tr>
0N/A * <tr><td>BI_RGB</td> <td>Uncompressed RLE</td> <td><= 8-bits/sample</td></tr>
0N/A * <tr><td>BI_RLE8</td> <td>8-bit Run Length Encoding</td> <td><= 8-bits/sample</td></tr>
0N/A * <tr><td>BI_RLE4</td> <td>4-bit Run Length Encoding</td> <td><= 4-bits/sample</td></tr>
0N/A * <tr><td>BI_BITFIELDS</td> <td>Packed data</td> <td> 16 or 32 bits/sample</td></tr>
0N/A * </table>
0N/A */
0N/Apublic class BMPImageWriteParam extends ImageWriteParam {
0N/A
0N/A private boolean topDown = false;
0N/A
0N/A /**
0N/A * Constructs a <code>BMPImageWriteParam</code> set to use a given
0N/A * <code>Locale</code> and with default values for all parameters.
0N/A *
0N/A * @param locale a <code>Locale</code> to be used to localize
0N/A * compression type names and quality descriptions, or
0N/A * <code>null</code>.
0N/A */
0N/A public BMPImageWriteParam(Locale locale) {
0N/A super(locale);
0N/A
0N/A // Set compression types ("BI_RGB" denotes uncompressed).
1501N/A compressionTypes = BMPConstants.compressionTypeNames.clone();
0N/A
0N/A // Set compression flag.
0N/A canWriteCompressed = true;
0N/A compressionMode = MODE_COPY_FROM_METADATA;
0N/A compressionType = compressionTypes[BMPConstants.BI_RGB];
0N/A }
0N/A
0N/A /**
0N/A * Constructs an <code>BMPImageWriteParam</code> object with default
0N/A * values for all parameters and a <code>null</code> <code>Locale</code>.
0N/A */
0N/A public BMPImageWriteParam() {
0N/A this(null);
0N/A }
0N/A
0N/A /**
0N/A * If set, the data will be written out in a top-down manner, the first
0N/A * scanline being written first.
0N/A *
0N/A * @param topDown whether the data are written in top-down order.
0N/A */
0N/A public void setTopDown(boolean topDown) {
0N/A this.topDown = topDown;
0N/A }
0N/A
0N/A /**
0N/A * Returns the value of the <code>topDown</code> parameter.
0N/A * The default is <code>false</code>.
0N/A *
0N/A * @return whether the data are written in top-down order.
0N/A */
0N/A public boolean isTopDown() {
0N/A return topDown;
0N/A }
0N/A}