提交 7c832cd1 编写于 作者: V vadim

8001119: [fingbugs] Evaluate necessity to make some arrays package protected

Reviewed-by: prr, bae
上级 78ab46ba
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.imageio.plugins.bmp;
public class BMPCompressionTypes {
private static final String[] compressionTypeNames =
{"BI_RGB", "BI_RLE8", "BI_RLE4", "BI_BITFIELDS", "BI_JPEG", "BI_PNG"};
static int getType(String typeString) {
for (int i = 0; i < compressionTypeNames.length; i++)
if (compressionTypeNames[i].equals(typeString))
return i;
return 0;
}
static String getName(int type) {
return compressionTypeNames[type];
}
public static String[] getCompressionTypes() {
return compressionTypeNames.clone();
}
}
...@@ -47,7 +47,4 @@ public interface BMPConstants { ...@@ -47,7 +47,4 @@ public interface BMPConstants {
static final int BI_BITFIELDS = 3; static final int BI_BITFIELDS = 3;
static final int BI_JPEG = 4; static final int BI_JPEG = 4;
static final int BI_PNG = 5; static final int BI_PNG = 5;
static final String[] compressionTypeNames =
{"BI_RGB", "BI_RLE8", "BI_RLE4", "BI_BITFIELDS", "BI_JPEG", "BI_PNG"};
} }
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
package com.sun.imageio.plugins.bmp; package com.sun.imageio.plugins.bmp;
import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.ColorModel; import java.awt.image.ColorModel;
import java.awt.image.ComponentSampleModel; import java.awt.image.ComponentSampleModel;
...@@ -42,7 +41,6 @@ import java.awt.image.Raster; ...@@ -42,7 +41,6 @@ import java.awt.image.Raster;
import java.awt.image.RenderedImage; import java.awt.image.RenderedImage;
import java.awt.image.SampleModel; import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel; import java.awt.image.SinglePixelPackedSampleModel;
import java.awt.image.WritableRaster;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
...@@ -51,22 +49,16 @@ import java.nio.ByteOrder; ...@@ -51,22 +49,16 @@ import java.nio.ByteOrder;
import java.util.Iterator; import java.util.Iterator;
import javax.imageio.IIOImage; import javax.imageio.IIOImage;
import javax.imageio.IIOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier; import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter; import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata; import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.spi.ImageWriterSpi; import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.stream.ImageOutputStream; import javax.imageio.stream.ImageOutputStream;
import javax.imageio.event.IIOWriteProgressListener; import javax.imageio.event.IIOWriteProgressListener;
import javax.imageio.event.IIOWriteWarningListener; import javax.imageio.event.IIOWriteWarningListener;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.imageio.plugins.bmp.BMPImageWriteParam; import javax.imageio.plugins.bmp.BMPImageWriteParam;
import com.sun.imageio.plugins.common.ImageUtil; import com.sun.imageio.plugins.common.ImageUtil;
...@@ -129,7 +121,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -129,7 +121,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
meta.compression = getPreferredCompressionType(imageType); meta.compression = getPreferredCompressionType(imageType);
if (param != null if (param != null
&& param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) { && param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
meta.compression = getCompressionType(param.getCompressionType()); meta.compression = BMPCompressionTypes.getType(param.getCompressionType());
} }
meta.bitsPerPixel = (short)imageType.getColorModel().getPixelSize(); meta.bitsPerPixel = (short)imageType.getColorModel().getPixelSize();
return meta; return meta;
...@@ -308,7 +300,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -308,7 +300,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
switch(bmpParam.getCompressionMode()) { switch(bmpParam.getCompressionMode()) {
case ImageWriteParam.MODE_EXPLICIT: case ImageWriteParam.MODE_EXPLICIT:
compressionType = getCompressionType(bmpParam.getCompressionType()); compressionType = BMPCompressionTypes.getType(bmpParam.getCompressionType());
break; break;
case ImageWriteParam.MODE_COPY_FROM_METADATA: case ImageWriteParam.MODE_COPY_FROM_METADATA:
compressionType = bmpImageMetadata.compression; compressionType = bmpImageMetadata.compression;
...@@ -323,12 +315,12 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -323,12 +315,12 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
if (!canEncodeImage(compressionType, colorModel, sampleModel)) { if (!canEncodeImage(compressionType, colorModel, sampleModel)) {
throw new IOException("Image can not be encoded with compression type " throw new IOException("Image can not be encoded with compression type "
+ compressionTypeNames[compressionType]); + BMPCompressionTypes.getName(compressionType));
} }
byte r[] = null, g[] = null, b[] = null, a[] = null; byte r[] = null, g[] = null, b[] = null, a[] = null;
if (compressionType == BMPConstants.BI_BITFIELDS) { if (compressionType == BI_BITFIELDS) {
bitsPerPixel = bitsPerPixel =
DataBuffer.getDataTypeSize(sampleModel.getDataType()); DataBuffer.getDataTypeSize(sampleModel.getDataType());
...@@ -372,7 +364,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -372,7 +364,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
// an exception related to unsupported image format // an exception related to unsupported image format
throw new IOException("Image can not be encoded with " + throw new IOException("Image can not be encoded with " +
"compression type " + "compression type " +
compressionTypeNames[compressionType]); BMPCompressionTypes.getName(compressionType));
} }
} }
writeMaskToPalette(rmask, 0, r, g, b, a); writeMaskToPalette(rmask, 0, r, g, b, a);
...@@ -511,8 +503,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -511,8 +503,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
* Images with any other compression type must be wrote in the * Images with any other compression type must be wrote in the
* bottom-up layout. * bottom-up layout.
*/ */
if (compressionType == BMPConstants.BI_RGB || if (compressionType == BI_RGB ||
compressionType == BMPConstants.BI_BITFIELDS) compressionType == BI_BITFIELDS)
{ {
isTopDown = bmpParam.isTopDown(); isTopDown = bmpParam.isTopDown();
} else { } else {
...@@ -543,7 +535,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -543,7 +535,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
if (isPalette == true) { if (isPalette == true) {
// write palette // write palette
if (compressionType == BMPConstants.BI_BITFIELDS) { if (compressionType == BI_BITFIELDS) {
// write masks for red, green and blue components. // write masks for red, green and blue components.
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
int mask = (a[i]&0xFF) + ((r[i]&0xFF)*0x100) + ((g[i]&0xFF)*0x10000) + ((b[i]&0xFF)*0x1000000); int mask = (a[i]&0xFF) + ((r[i]&0xFF)*0x100) + ((g[i]&0xFF)*0x10000) + ((b[i]&0xFF)*0x1000000);
...@@ -571,8 +563,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -571,8 +563,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
int l; int l;
if (compressionType == BMPConstants.BI_JPEG || if (compressionType == BI_JPEG ||
compressionType == BMPConstants.BI_PNG) { compressionType == BI_PNG) {
// prepare embedded buffer // prepare embedded buffer
embedded_stream = new ByteArrayOutputStream(); embedded_stream = new ByteArrayOutputStream();
...@@ -657,7 +649,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -657,7 +649,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
pos = sppsm.getOffset(startX, startY); pos = sppsm.getOffset(startX, startY);
} }
if (compressionType == BMPConstants.BI_RGB || compressionType == BMPConstants.BI_BITFIELDS){ if (compressionType == BI_RGB || compressionType == BI_BITFIELDS){
switch(dataType) { switch(dataType) {
case DataBuffer.TYPE_BYTE: case DataBuffer.TYPE_BYTE:
byte[] bdata = byte[] bdata =
...@@ -687,7 +679,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -687,7 +679,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
for(int k=0; k<padding; k++) { for(int k=0; k<padding; k++) {
stream.writeByte(0); stream.writeByte(0);
} }
} else if (compressionType == BMPConstants.BI_RLE4) { } else if (compressionType == BI_RLE4) {
if (bpixels == null || bpixels.length < scanlineBytes) if (bpixels == null || bpixels.length < scanlineBytes)
bpixels = new byte[scanlineBytes]; bpixels = new byte[scanlineBytes];
src.getPixels(srcRect.x, srcRect.y, src.getPixels(srcRect.x, srcRect.y,
...@@ -696,7 +688,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -696,7 +688,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
bpixels[h] = (byte)pixels[h]; bpixels[h] = (byte)pixels[h];
} }
encodeRLE4(bpixels, scanlineBytes); encodeRLE4(bpixels, scanlineBytes);
} else if (compressionType == BMPConstants.BI_RLE8) { } else if (compressionType == BI_RLE8) {
//byte[] bdata = //byte[] bdata =
// ((DataBufferByte)src.getDataBuffer()).getData(); // ((DataBufferByte)src.getDataBuffer()).getData();
//System.out.println("bdata.length="+bdata.length); //System.out.println("bdata.length="+bdata.length);
...@@ -734,8 +726,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -734,8 +726,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
processImageProgress(100.0f * (((float)i) / ((float)h))); processImageProgress(100.0f * (((float)i) / ((float)h)));
} }
if (compressionType == BMPConstants.BI_RLE4 || if (compressionType == BI_RLE4 ||
compressionType == BMPConstants.BI_RLE8) { compressionType == BI_RLE8) {
// Write the RLE EOF marker and // Write the RLE EOF marker and
stream.writeByte(0); stream.writeByte(0);
stream.writeByte(1); stream.writeByte(1);
...@@ -793,7 +785,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -793,7 +785,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
break; break;
case 4: case 4:
if (compressionType == BMPConstants.BI_RLE4){ if (compressionType == BI_RLE4){
byte[] bipixels = new byte[scanlineBytes]; byte[] bipixels = new byte[scanlineBytes];
for (int h=0; h<scanlineBytes; h++) { for (int h=0; h<scanlineBytes; h++) {
bipixels[h] = (byte)pixels[l++]; bipixels[h] = (byte)pixels[l++];
...@@ -814,7 +806,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -814,7 +806,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
break; break;
case 8: case 8:
if(compressionType == BMPConstants.BI_RLE8) { if(compressionType == BI_RLE8) {
for (int h=0; h<scanlineBytes; h++) { for (int h=0; h<scanlineBytes; h++) {
bpixels[h] = (byte)pixels[l++]; bpixels[h] = (byte)pixels[l++];
} }
...@@ -841,7 +833,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -841,7 +833,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
*/ */
for (int j = 0, m = 0; j < scanlineBytes; m++) { for (int j = 0, m = 0; j < scanlineBytes; m++) {
spixels[m] = 0; spixels[m] = 0;
if (compressionType == BMPConstants.BI_RGB) { if (compressionType == BI_RGB) {
/* /*
* please note that despite other cases, * please note that despite other cases,
* the 16bpp BI_RGB requires the RGB data order * the 16bpp BI_RGB requires the RGB data order
...@@ -910,7 +902,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -910,7 +902,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
*/ */
for (int j = 0, m = 0; j < scanlineBytes; m++) { for (int j = 0, m = 0; j < scanlineBytes; m++) {
ipixels[m] = 0; ipixels[m] = 0;
if (compressionType == BMPConstants.BI_RGB) { if (compressionType == BI_RGB) {
ipixels[m] = ipixels[m] =
((0xff & pixels[j + 2]) << 16) | ((0xff & pixels[j + 2]) << 16) |
((0xff & pixels[j + 1]) << 8) | ((0xff & pixels[j + 1]) << 8) |
...@@ -945,8 +937,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -945,8 +937,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
} }
// Write out the padding // Write out the padding
if (compressionType == BMPConstants.BI_RGB || if (compressionType == BI_RGB ||
compressionType == BMPConstants.BI_BITFIELDS) compressionType == BI_BITFIELDS)
{ {
for(k=0; k<padding; k++) { for(k=0; k<padding; k++) {
stream.writeByte(0); stream.writeByte(0);
...@@ -1329,17 +1321,10 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants { ...@@ -1329,17 +1321,10 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
stream = null; stream = null;
} }
private int getCompressionType(String typeString) {
for (int i = 0; i < BMPConstants.compressionTypeNames.length; i++)
if (BMPConstants.compressionTypeNames[i].equals(typeString))
return i;
return 0;
}
private void writeEmbedded(IIOImage image, private void writeEmbedded(IIOImage image,
ImageWriteParam bmpParam) throws IOException { ImageWriteParam bmpParam) throws IOException {
String format = String format =
compressionType == BMPConstants.BI_JPEG ? "jpeg" : "png"; compressionType == BI_JPEG ? "jpeg" : "png";
Iterator iterator = ImageIO.getImageWritersByFormatName(format); Iterator iterator = ImageIO.getImageWritersByFormatName(format);
ImageWriter writer = null; ImageWriter writer = null;
if (iterator.hasNext()) if (iterator.hasNext())
......
...@@ -219,7 +219,7 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants { ...@@ -219,7 +219,7 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
// CompressionTypeName // CompressionTypeName
IIOMetadataNode subNode = new IIOMetadataNode("CompressionTypeName"); IIOMetadataNode subNode = new IIOMetadataNode("CompressionTypeName");
subNode.setAttribute("value", compressionTypeNames[compression]); subNode.setAttribute("value", BMPCompressionTypes.getName(compression));
node.appendChild(subNode); node.appendChild(subNode);
return node; return node;
} }
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
package com.sun.imageio.plugins.gif; package com.sun.imageio.plugins.gif;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.metadata.IIOInvalidTreeException; import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode; import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.metadata.IIOMetadataFormat;
import javax.imageio.metadata.IIOMetadataFormatImpl; import javax.imageio.metadata.IIOMetadataFormatImpl;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -41,7 +38,7 @@ public class GIFStreamMetadata extends GIFMetadata { ...@@ -41,7 +38,7 @@ public class GIFStreamMetadata extends GIFMetadata {
static final String static final String
nativeMetadataFormatName = "javax_imageio_gif_stream_1.0"; nativeMetadataFormatName = "javax_imageio_gif_stream_1.0";
public static final String[] versionStrings = { "87a", "89a" }; static final String[] versionStrings = { "87a", "89a" };
public String version; // 87a or 89a public String version; // 87a or 89a
public int logicalScreenWidth; public int logicalScreenWidth;
...@@ -52,7 +49,7 @@ public class GIFStreamMetadata extends GIFMetadata { ...@@ -52,7 +49,7 @@ public class GIFStreamMetadata extends GIFMetadata {
public int backgroundColorIndex; // Valid if globalColorTable != null public int backgroundColorIndex; // Valid if globalColorTable != null
public boolean sortFlag; // Valid if globalColorTable != null public boolean sortFlag; // Valid if globalColorTable != null
public static final String[] colorTableSizes = { static final String[] colorTableSizes = {
"2", "4", "8", "16", "32", "64", "128", "256" "2", "4", "8", "16", "32", "64", "128", "256"
}; };
......
...@@ -25,14 +25,11 @@ ...@@ -25,14 +25,11 @@
package com.sun.imageio.plugins.jpeg; package com.sun.imageio.plugins.jpeg;
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.ImageTypeSpecifier; import javax.imageio.ImageTypeSpecifier;
import javax.imageio.plugins.jpeg.JPEGQTable; import javax.imageio.plugins.jpeg.JPEGQTable;
import javax.imageio.plugins.jpeg.JPEGHuffmanTable; import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
import java.awt.image.ColorModel; import java.awt.image.ColorModel;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_ColorSpace;
...@@ -172,9 +169,9 @@ public class JPEG { ...@@ -172,9 +169,9 @@ public class JPEG {
public static final String vendor = "Oracle Corporation"; public static final String vendor = "Oracle Corporation";
public static final String version = "0.5"; public static final String version = "0.5";
// Names of the formats we can read or write // Names of the formats we can read or write
public static final String [] names = {"JPEG", "jpeg", "JPG", "jpg"}; static final String [] names = {"JPEG", "jpeg", "JPG", "jpg"};
public static final String [] suffixes = {"jpg", "jpeg"}; static final String [] suffixes = {"jpg", "jpeg"};
public static final String [] MIMETypes = {"image/jpeg"}; static final String [] MIMETypes = {"image/jpeg"};
public static final String nativeImageMetadataFormatName = public static final String nativeImageMetadataFormatName =
"javax_imageio_jpeg_image_1.0"; "javax_imageio_jpeg_image_1.0";
public static final String nativeImageMetadataFormatClassName = public static final String nativeImageMetadataFormatClassName =
...@@ -201,12 +198,12 @@ public class JPEG { ...@@ -201,12 +198,12 @@ public class JPEG {
public static final int NUM_JCS_CODES = JCS_YCCK+1; public static final int NUM_JCS_CODES = JCS_YCCK+1;
/** IJG can handle up to 4-channel JPEGs */ /** IJG can handle up to 4-channel JPEGs */
public static final int [] [] bandOffsets = {{0}, static final int [] [] bandOffsets = {{0},
{0, 1}, {0, 1},
{0, 1, 2}, {0, 1, 2},
{0, 1, 2, 3}}; {0, 1, 2, 3}};
public static final int [] bOffsRGB = { 2, 1, 0 }; static final int [] bOffsRGB = { 2, 1, 0 };
/* These are kept in the inner class to avoid static initialization /* These are kept in the inner class to avoid static initialization
* of the CMM class until someone actually needs it. * of the CMM class until someone actually needs it.
......
...@@ -29,12 +29,10 @@ import java.awt.image.ColorModel; ...@@ -29,12 +29,10 @@ import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel; import java.awt.image.IndexColorModel;
import java.awt.image.SampleModel; import java.awt.image.SampleModel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import javax.imageio.ImageTypeSpecifier; import javax.imageio.ImageTypeSpecifier;
import javax.imageio.metadata.IIOInvalidTreeException; import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadata; import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataFormat;
import javax.imageio.metadata.IIOMetadataFormatImpl; import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.metadata.IIOMetadataNode; import javax.imageio.metadata.IIOMetadataNode;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -49,42 +47,42 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { ...@@ -49,42 +47,42 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
= "com.sun.imageio.plugins.png.PNGMetadataFormat"; = "com.sun.imageio.plugins.png.PNGMetadataFormat";
// Color types for IHDR chunk // Color types for IHDR chunk
public static final String[] IHDR_colorTypeNames = { static final String[] IHDR_colorTypeNames = {
"Grayscale", null, "RGB", "Palette", "Grayscale", null, "RGB", "Palette",
"GrayAlpha", null, "RGBAlpha" "GrayAlpha", null, "RGBAlpha"
}; };
public static final int[] IHDR_numChannels = { static final int[] IHDR_numChannels = {
1, 0, 3, 3, 2, 0, 4 1, 0, 3, 3, 2, 0, 4
}; };
// Bit depths for IHDR chunk // Bit depths for IHDR chunk
public static final String[] IHDR_bitDepths = { static final String[] IHDR_bitDepths = {
"1", "2", "4", "8", "16" "1", "2", "4", "8", "16"
}; };
// Compression methods for IHDR chunk // Compression methods for IHDR chunk
public static final String[] IHDR_compressionMethodNames = { static final String[] IHDR_compressionMethodNames = {
"deflate" "deflate"
}; };
// Filter methods for IHDR chunk // Filter methods for IHDR chunk
public static final String[] IHDR_filterMethodNames = { static final String[] IHDR_filterMethodNames = {
"adaptive" "adaptive"
}; };
// Interlace methods for IHDR chunk // Interlace methods for IHDR chunk
public static final String[] IHDR_interlaceMethodNames = { static final String[] IHDR_interlaceMethodNames = {
"none", "adam7" "none", "adam7"
}; };
// Compression methods for iCCP chunk // Compression methods for iCCP chunk
public static final String[] iCCP_compressionMethodNames = { static final String[] iCCP_compressionMethodNames = {
"deflate" "deflate"
}; };
// Compression methods for zTXt chunk // Compression methods for zTXt chunk
public static final String[] zTXt_compressionMethodNames = { static final String[] zTXt_compressionMethodNames = {
"deflate" "deflate"
}; };
...@@ -95,12 +93,12 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { ...@@ -95,12 +93,12 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public static final int PHYS_UNIT_METER = 1; public static final int PHYS_UNIT_METER = 1;
// Unit specifiers for pHYs chunk // Unit specifiers for pHYs chunk
public static final String[] unitSpecifierNames = { static final String[] unitSpecifierNames = {
"unknown", "meter" "unknown", "meter"
}; };
// Rendering intents for sRGB chunk // Rendering intents for sRGB chunk
public static final String[] renderingIntentNames = { static final String[] renderingIntentNames = {
"Perceptual", // 0 "Perceptual", // 0
"Relative colorimetric", // 1 "Relative colorimetric", // 1
"Saturation", // 2 "Saturation", // 2
...@@ -109,7 +107,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { ...@@ -109,7 +107,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}; };
// Color space types for Chroma->ColorSpaceType node // Color space types for Chroma->ColorSpaceType node
public static final String[] colorSpaceTypeNames = { static final String[] colorSpaceTypeNames = {
"GRAY", null, "RGB", "RGB", "GRAY", null, "RGB", "RGB",
"GRAY", null, "RGB" "GRAY", null, "RGB"
}; };
......
...@@ -29,6 +29,7 @@ import java.util.Locale; ...@@ -29,6 +29,7 @@ import java.util.Locale;
import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriteParam;
import com.sun.imageio.plugins.bmp.BMPConstants; import com.sun.imageio.plugins.bmp.BMPConstants;
import com.sun.imageio.plugins.bmp.BMPCompressionTypes;
/** /**
* A subclass of <code>ImageWriteParam</code> for encoding images in * A subclass of <code>ImageWriteParam</code> for encoding images in
...@@ -78,7 +79,7 @@ public class BMPImageWriteParam extends ImageWriteParam { ...@@ -78,7 +79,7 @@ public class BMPImageWriteParam extends ImageWriteParam {
super(locale); super(locale);
// Set compression types ("BI_RGB" denotes uncompressed). // Set compression types ("BI_RGB" denotes uncompressed).
compressionTypes = BMPConstants.compressionTypeNames.clone(); compressionTypes = BMPCompressionTypes.getCompressionTypes();
// Set compression flag. // Set compression flag.
canWriteCompressed = true; canWriteCompressed = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册