summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/javax/imageio/bmp
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/javax/imageio/bmp')
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java148
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java10
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPException.java2
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java64
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java99
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java86
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java22
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java20
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java28
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeBF16.java75
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java83
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB1.java56
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java44
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB4.java62
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB8.java58
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE4.java211
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE8.java151
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java8
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java12
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java8
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java10
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java8
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java6
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java22
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java22
25 files changed, 648 insertions, 667 deletions
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
index df53f2e3dee..10846193189 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
@@ -49,11 +49,11 @@ public abstract class BMPDecoder {
protected BMPInfoHeader infoHeader;
protected BMPFileHeader fileHeader;
protected long offset;
-
+
public BMPDecoder(BMPFileHeader fh, BMPInfoHeader ih){
- fileHeader = fh;
- infoHeader = ih;
- offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
/**
@@ -61,108 +61,108 @@ public abstract class BMPDecoder {
* decoder.
*/
public static BMPDecoder getDecoder(BMPFileHeader fh, BMPInfoHeader ih){
- switch(ih.getCompression()){
- case BMPInfoHeader.BI_RGB: // uncompressed RGB
- switch(ih.getBitCount()){
- case 32:
- return new DecodeBF32(fh, ih, true);
+ switch(ih.getCompression()){
+ case BMPInfoHeader.BI_RGB: // uncompressed RGB
+ switch(ih.getBitCount()){
+ case 32:
+ return new DecodeBF32(fh, ih, true);
+
+ case 24:
+ return new DecodeRGB24(fh, ih);
- case 24:
- return new DecodeRGB24(fh, ih);
+ case 16:
+ return new DecodeBF16(fh, ih, true);
- case 16:
- return new DecodeBF16(fh, ih, true);
+ case 8:
+ return new DecodeRGB8(fh, ih);
- case 8:
- return new DecodeRGB8(fh, ih);
+ case 4:
+ return new DecodeRGB4(fh, ih);
- case 4:
- return new DecodeRGB4(fh, ih);
+ case 1:
+ return new DecodeRGB1(fh, ih);
- case 1:
- return new DecodeRGB1(fh, ih);
+ default:
+ return null;
+ }
- default:
- return null;
- }
+ case BMPInfoHeader.BI_RLE8:
+ return new DecodeRLE8(fh, ih);
- case BMPInfoHeader.BI_RLE8:
- return new DecodeRLE8(fh, ih);
+ case BMPInfoHeader.BI_RLE4:
+ return new DecodeRLE4(fh, ih);
- case BMPInfoHeader.BI_RLE4:
- return new DecodeRLE4(fh, ih);
+ case BMPInfoHeader.BI_BITFIELDS:
+ switch(ih.getBitCount()){
+ case 16:
+ return new DecodeBF16(fh, ih, false);
- case BMPInfoHeader.BI_BITFIELDS:
- switch(ih.getBitCount()){
- case 16:
- return new DecodeBF16(fh, ih, false);
+ case 32:
+ return new DecodeBF32(fh, ih, false);
- case 32:
- return new DecodeBF32(fh, ih, false);
+ default:
+ return null;
+ }
- default:
- return null;
- }
-
- default:
- return null;
- }
+ default:
+ return null;
+ }
}
/**
* The image decoder.
*/
- public abstract BufferedImage decode(ImageInputStream in)
- throws IOException, BMPException;
+ public abstract BufferedImage decode(ImageInputStream in)
+ throws IOException, BMPException;
/**
* Reads r,g,b bit masks from an inputstream
*/
protected int[] readBitMasks(ImageInputStream in) throws IOException {
- int[] bitmasks = new int[3];
- byte[] temp = new byte[12];
- if(in.read(temp) != 12)
- throw new IOException("Couldn't read bit masks.");
- offset += 12;
-
- ByteBuffer buf = ByteBuffer.wrap(temp);
- buf.order(ByteOrder.LITTLE_ENDIAN);
- bitmasks[0] = buf.getInt();
- bitmasks[1] = buf.getInt();
- bitmasks[2] = buf.getInt();
- return bitmasks;
+ int[] bitmasks = new int[3];
+ byte[] temp = new byte[12];
+ if(in.read(temp) != 12)
+ throw new IOException("Couldn't read bit masks.");
+ offset += 12;
+
+ ByteBuffer buf = ByteBuffer.wrap(temp);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+ bitmasks[0] = buf.getInt();
+ bitmasks[1] = buf.getInt();
+ bitmasks[2] = buf.getInt();
+ return bitmasks;
}
/**
- * Reads an N-color palette from an inputstream in RGBQUAD format and
+ * Reads an N-color palette from an inputstream in RGBQUAD format and
* returns an equivalent ColorModel object
*/
protected IndexColorModel readPalette(ImageInputStream in) throws IOException {
- int N = infoHeader.getNumberOfPaletteEntries();
- byte[] r = new byte[N];
- byte[] g = new byte[N];
- byte[] b = new byte[N];
- for(int i=0;i<N;i++){
- byte[] RGBquad = new byte[4];
- if(in.read(RGBquad) != 4)
- throw new IOException("Error reading palette information.");
- // RGBQUAD structure is b,g,r,0
- r[i] = RGBquad[2];
- g[i] = RGBquad[1];
- b[i] = RGBquad[0];
- }
-
- offset += 4*N;
- return new IndexColorModel(8, N, r, g, b);
+ int N = infoHeader.getNumberOfPaletteEntries();
+ byte[] r = new byte[N];
+ byte[] g = new byte[N];
+ byte[] b = new byte[N];
+ for(int i=0;i<N;i++){
+ byte[] RGBquad = new byte[4];
+ if(in.read(RGBquad) != 4)
+ throw new IOException("Error reading palette information.");
+ // RGBQUAD structure is b,g,r,0
+ r[i] = RGBquad[2];
+ g[i] = RGBquad[1];
+ b[i] = RGBquad[0];
+ }
+
+ offset += 4*N;
+ return new IndexColorModel(8, N, r, g, b);
}
/**
* Read bytes to the start of the image data
*/
protected void skipToImage(ImageInputStream in) throws IOException {
- byte[] d = new byte[1];
- long n = fileHeader.getOffset() - offset;
- for(int i=0;i<n;i++)
- in.read(d);
+ byte[] d = new byte[1];
+ long n = fileHeader.getOffset() - offset;
+ for(int i=0;i<n;i++)
+ in.read(d);
}
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java
index fc8dcf00f67..d7c54c0d6ac 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java
@@ -1,4 +1,4 @@
-/* BMPEncoder.java --
+/* BMPEncoder.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -59,7 +59,7 @@ public abstract class BMPEncoder
/**
* Determines the coding type of the bitmap and returns the corresponding
* encoder.
- *
+ *
* @param fh - the file header
* @param ih - the info header
* @return the appropriate encoder
@@ -94,17 +94,17 @@ public abstract class BMPEncoder
}
case BMPInfoHeader.BI_RLE4:
return new EncodeRLE4(fh, ih);
-
+
case BMPInfoHeader.BI_RLE8:
return new EncodeRLE8(fh, ih);
default:
return null;
}
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPException.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPException.java
index d3c62e7597e..0ba3c6c74fb 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPException.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPException.java
@@ -42,6 +42,6 @@ import javax.imageio.IIOException;
public class BMPException extends IIOException {
public BMPException(String message){
- super(message);
+ super(message);
}
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
index 4ba32d3c30a..0cfd72323ab 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
@@ -52,45 +52,45 @@ public class BMPFileHeader {
/** Bitmap file size, in bytes. */
protected long bfSize;
-
+
/** Offset from the beginning of the file to the bitmap data */
protected long bfOffBits;
/** BITMAPFILEHEADER is 14 bytes */
public static final int SIZE = 14;
private static final int BITMAPINFOHEADER_SIZE = 40;
-
+
/**
* Creates the header from an input stream, which is not closed.
- *
+ *
* @throws IOException if an I/O error occured.
* @throws BMPException if the header was invalid
*/
public BMPFileHeader(ImageInputStream in) throws IOException, BMPException {
byte[] data = new byte[SIZE];
- if (in.read(data) != SIZE)
- throw new IOException("Couldn't read header.");
- ByteBuffer buf = ByteBuffer.wrap(data);
+ if (in.read(data) != SIZE)
+ throw new IOException("Couldn't read header.");
+ ByteBuffer buf = ByteBuffer.wrap(data);
- if(buf.getShort(0) != bfType)
- throw new BMPException("Not a BMP file.");
+ if(buf.getShort(0) != bfType)
+ throw new BMPException("Not a BMP file.");
- buf.order(ByteOrder.LITTLE_ENDIAN);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
- // get size (keep unsigned)
- bfSize = ((long)buf.getInt(2) & (0xFFFFFFFF));
+ // get size (keep unsigned)
+ bfSize = ((long)buf.getInt(2) & (0xFFFFFFFF));
- // Two reserved shorts are here, and should be zero,
- // perhaps they should be tested to be zero, but I don't
- // feel this strictness is necessary.
-
- bfOffBits = ((long)buf.getInt(10) & (0xFFFFFFFF));
+ // Two reserved shorts are here, and should be zero,
+ // perhaps they should be tested to be zero, but I don't
+ // feel this strictness is necessary.
+
+ bfOffBits = ((long)buf.getInt(10) & (0xFFFFFFFF));
}
-
+
/**
* Creates the header from an output stream, which is not closed.
- *
+ *
* @param out - the image output stream
* @param im - the image
* @throws IOException if an I/O error occured.
@@ -100,7 +100,7 @@ public class BMPFileHeader {
RenderedImage img = im.getRenderedImage();
int w = img.getWidth();
int h = img.getHeight();
-
+
bfOffBits = SIZE + BITMAPINFOHEADER_SIZE;
bfSize = ((w * h) * 3) + ((4 - ((w * 3) % 4)) * h) + bfOffBits;
@@ -109,45 +109,43 @@ public class BMPFileHeader {
/**
* Writes the header to an output stream, which is not closed or flushed.
- *
+ *
* @throws IOException if an I/O error occured.
*/
public void write(ImageOutputStream out) throws IOException {
- ByteBuffer buf = ByteBuffer.allocate(SIZE);
- buf.putShort(0, bfType); // ID
- buf.putInt(2, (int)(bfSize & (0xFFFFFFFF))); // size
- buf.putInt(6, 0); // 4 reserved bytes set to zero
- buf.putInt(7, (int)(bfOffBits & (0xFFFFFFFF))); // size
- out.write(buf.array());
+ ByteBuffer buf = ByteBuffer.allocate(SIZE);
+ buf.putShort(0, bfType); // ID
+ buf.putInt(2, (int)(bfSize & (0xFFFFFFFF))); // size
+ buf.putInt(6, 0); // 4 reserved bytes set to zero
+ buf.putInt(7, (int)(bfOffBits & (0xFFFFFFFF))); // size
+ out.write(buf.array());
}
-
+
/**
* Sets the file size
*/
public void setSize(long size){
- bfSize = size;
+ bfSize = size;
}
/**
* Sets the bitmap offset within the file
*/
public void setOffset(long offset){
- bfOffBits = offset;
+ bfOffBits = offset;
}
/**
* Gets the file size
*/
public long getSize(){
- return bfSize;
+ return bfSize;
}
/**
* Gets the bitmap offset within the file
*/
public long getOffset(){
- return bfOffBits;
+ return bfOffBits;
}
}
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
index f1359da6adb..7b136bdf567 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
@@ -51,101 +51,98 @@ public class BMPImageReader extends ImageReader {
private BMPDecoder decoder;
protected BMPImageReader(ImageReaderSpi originatingProvider){
- super(originatingProvider);
- infoHeader = null;
- fileHeader = null;
- decoder = null;
+ super(originatingProvider);
+ infoHeader = null;
+ fileHeader = null;
+ decoder = null;
}
- private void validateIndex(int imageIndex)
- throws IndexOutOfBoundsException {
- if (imageIndex != 0)
- throw new IndexOutOfBoundsException("Invalid image index.");
+ private void validateIndex(int imageIndex)
+ throws IndexOutOfBoundsException {
+ if (imageIndex != 0)
+ throw new IndexOutOfBoundsException("Invalid image index.");
}
public void setInput(Object input) {
- super.setInput(input);
+ super.setInput(input);
}
- public void setInput(Object input,
- boolean seekForwardOnly,
- boolean ignoreMetadata) {
- super.setInput(input, seekForwardOnly, ignoreMetadata);
+ public void setInput(Object input,
+ boolean seekForwardOnly,
+ boolean ignoreMetadata) {
+ super.setInput(input, seekForwardOnly, ignoreMetadata);
}
-
+
public void setInput(Object input, boolean isStreamable) {
- super.setInput(input, isStreamable);
-
- if (!(input instanceof ImageInputStream))
- throw new IllegalArgumentException("Input not an ImageInputStream.");
+ super.setInput(input, isStreamable);
+
+ if (!(input instanceof ImageInputStream))
+ throw new IllegalArgumentException("Input not an ImageInputStream.");
}
private void checkStream() throws IOException {
- if (!(input instanceof ImageInputStream))
- throw new IllegalStateException("Input not an ImageInputStream.");
- if(input == null)
- throw new IllegalStateException("No input stream.");
+ if (!(input instanceof ImageInputStream))
+ throw new IllegalStateException("Input not an ImageInputStream.");
+ if(input == null)
+ throw new IllegalStateException("No input stream.");
}
private void readHeaders() throws IOException, IIOException {
- if(fileHeader != null)
- return;
+ if(fileHeader != null)
+ return;
- checkStream();
+ checkStream();
- fileHeader = new BMPFileHeader((ImageInputStream)input);
- infoHeader = new BMPInfoHeader((ImageInputStream)input);
- decoder = BMPDecoder.getDecoder(fileHeader, infoHeader);
+ fileHeader = new BMPFileHeader((ImageInputStream)input);
+ infoHeader = new BMPInfoHeader((ImageInputStream)input);
+ decoder = BMPDecoder.getDecoder(fileHeader, infoHeader);
}
-
+
public int getWidth(int imageIndex) throws IOException {
- validateIndex(imageIndex);
- readHeaders();
- return infoHeader.getWidth();
+ validateIndex(imageIndex);
+ readHeaders();
+ return infoHeader.getWidth();
}
public int getHeight(int imageIndex) throws IOException {
- validateIndex(imageIndex);
- readHeaders();
- return infoHeader.getHeight();
+ validateIndex(imageIndex);
+ readHeaders();
+ return infoHeader.getHeight();
}
public Iterator getImageTypes(int imageIndex){
- validateIndex(imageIndex);
- return null;
+ validateIndex(imageIndex);
+ return null;
}
/**
* Returns the number of images. BMP files can only contain a single one.
*/
public int getNumImages(boolean allowSearch){
- return 1;
+ return 1;
}
// FIXME: Support metadata
public IIOMetadata getImageMetadata(int imageIndex){
- validateIndex(imageIndex);
- return null;
+ validateIndex(imageIndex);
+ return null;
}
// FIXME: Support metadata
public IIOMetadata getStreamMetadata(){
- return null;
+ return null;
}
/**
- * Reads the image indexed by imageIndex and returns it as
+ * Reads the image indexed by imageIndex and returns it as
* a complete BufferedImage, using a supplied ImageReadParam.
- */
- public BufferedImage read(int imageIndex, ImageReadParam param)
- throws IOException, IIOException {
- validateIndex(imageIndex);
- readHeaders();
- return decoder.decode((ImageInputStream)input);
+ */
+ public BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException, IIOException {
+ validateIndex(imageIndex);
+ readHeaders();
+ return decoder.decode((ImageInputStream)input);
}
}
-
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
index cf8547c713f..5d027963a14 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
@@ -48,15 +48,15 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
static final String vendorName = "GNU";
static final String version = "0.1";
static final String readerClassName =
- "gnu.javax.imageio.bmp.BMPImageReader";
+ "gnu.javax.imageio.bmp.BMPImageReader";
static final String[] names = { "Microsoft Windows BMP" };
static final String[] suffixes = { ".bmp", ".bm" };
static final String[] MIMETypes = {
- "image/bmp",
- "image/x-windows-bmp"};
- static final String[] writerSpiNames =
+ "image/bmp",
+ "image/x-windows-bmp"};
+ static final String[] writerSpiNames =
{ "gnu.javax.imageio.bmp.BMPImageWriterSpi" };
-
+
static final boolean supportsStandardStreamMetadataFormat = false;
static final String nativeStreamMetadataFormatName = null;
static final String nativeStreamMetadataFormatClassName = null;
@@ -67,50 +67,50 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
static final String nativeImageMetadataFormatClassName = null;
static final String[] extraImageMetadataFormatNames = null;
static final String[] extraImageMetadataFormatClassNames = null;
-
+
public BMPImageReaderSpi() {
- super(vendorName, version,
- names, suffixes, MIMETypes,
- readerClassName,
- STANDARD_INPUT_TYPE, // Accept ImageInputStreams
- writerSpiNames,
- supportsStandardStreamMetadataFormat,
- nativeStreamMetadataFormatName,
- nativeStreamMetadataFormatClassName,
- extraStreamMetadataFormatNames,
- extraStreamMetadataFormatClassNames,
- supportsStandardImageMetadataFormat,
- nativeImageMetadataFormatName,
- nativeImageMetadataFormatClassName,
- extraImageMetadataFormatNames,
- extraImageMetadataFormatClassNames);
+ super(vendorName, version,
+ names, suffixes, MIMETypes,
+ readerClassName,
+ STANDARD_INPUT_TYPE, // Accept ImageInputStreams
+ writerSpiNames,
+ supportsStandardStreamMetadataFormat,
+ nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName,
+ extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames,
+ supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName,
+ nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames,
+ extraImageMetadataFormatClassNames);
}
-
+
public String getDescription(Locale locale) {
- return "Microsoft BMP v3";
+ return "Microsoft BMP v3";
}
-
+
public boolean canDecodeInput(Object input)
- throws IOException {
- if (!(input instanceof ImageInputStream))
- return false;
-
- ImageInputStream in = (ImageInputStream)input;
- boolean retval;
-
- in.mark();
- try {
- new BMPFileHeader(in);
- retval = true;
- } catch(BMPException e){
- retval = false;
- }
- in.reset();
-
- return retval;
+ throws IOException {
+ if (!(input instanceof ImageInputStream))
+ return false;
+
+ ImageInputStream in = (ImageInputStream)input;
+ boolean retval;
+
+ in.mark();
+ try {
+ new BMPFileHeader(in);
+ retval = true;
+ } catch(BMPException e){
+ retval = false;
+ }
+ in.reset();
+
+ return retval;
}
-
+
public ImageReader createReaderInstance(Object extension) {
- return new BMPImageReader(this);
+ return new BMPImageReader(this);
}
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java
index be42ffae1ee..407e66a72dd 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java
@@ -1,4 +1,4 @@
-/* BMPImageWriter.java --
+/* BMPImageWriter.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,7 +57,7 @@ public class BMPImageWriter
/**
* Construct an bmp image writer.
- *
+ *
* @param originatingProvider - the provider that is constructing this image
* writer, or null
*/
@@ -68,13 +68,13 @@ public class BMPImageWriter
fileHeader = null;
infoHeader = null;
}
-
+
/**
* Convert IIOMetadata from an input reader format, returning an IIOMetadata
* suitable for use by an image writer. The ImageTypeSpecifier specifies the
* destination image type. An optional ImageWriteParam argument is available
* in case the image writing parameters affect the metadata conversion.
- *
+ *
* @param inData - the metadata coming from an image reader
* @param imageType - the output image type of the writer
* @param param - the image writing parameters or null
@@ -91,7 +91,7 @@ public class BMPImageWriter
throw new IllegalArgumentException("IIOMetadata and ImageTypeSpecifier cannot be null.");
return null;
}
-
+
/**
* Convert IIOMetadata from an input stream format, returning an
* IIOMetadata suitable for use by an image writer.
@@ -115,7 +115,7 @@ public class BMPImageWriter
throw new IllegalArgumentException("IIOMetadata cannot be null.");
return null;
}
-
+
/**
* Get a metadata object appropriate for encoding an image specified
* by the given image type specifier and optional image write
@@ -131,7 +131,7 @@ public class BMPImageWriter
// FIXME: Support metadata.
return null;
}
-
+
/**
* Get a metadata object appropriate for encoding the default image
* type handled by this writer, optionally considering image write
@@ -146,7 +146,7 @@ public class BMPImageWriter
// FIXME: Support metadata.
return null;
}
-
+
/**
* Write an image stream, including thumbnails and metadata to the
* output stream. The output must have been set prior to this
@@ -173,16 +173,16 @@ public class BMPImageWriter
fileHeader = new BMPFileHeader(out, image);
infoHeader = new BMPInfoHeader(out, image, param);
encoder = BMPEncoder.getEncoder(fileHeader, infoHeader);
-
+
if (encoder != null)
encoder.encode(out, streamMetadata, image, param);
else
throw new BMPException("Encoder has not been initialized.");
}
-
+
/**
* Checks the output stream.
- *
+ *
* @throws IOException if there is an error with the output stream
*/
private void checkStream() throws IOException
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java
index 32f9f59d1ac..e158dcfd722 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java
@@ -1,4 +1,4 @@
-/* BMPImageWriterSpi.java --
+/* BMPImageWriterSpi.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ public class BMPImageWriterSpi
static final String[] suffixes = { ".bmp", ".bm" };
static final String[] MIMETypes = { "image/bmp", "image/x-windows-bmp" };
static final String[] readerSpiNames = { "gnu.javax.imageio.bmp.BMPImageReaderSpi" };
-
+
static final boolean supportsStandardStreamMetadataFormat = false;
static final String nativeStreamMetadataFormatName = null;
static final String nativeStreamMetadataFormatClassName = null;
@@ -66,9 +66,9 @@ public class BMPImageWriterSpi
static final String nativeImageMetadataFormatClassName = null;
static final String[] extraImageMetadataFormatNames = null;
static final String[] extraImageMetadataFormatClassNames = null;
-
+
private BMPImageWriter writerInstance;
-
+
public BMPImageWriterSpi()
{
super(vendorName, version, names, suffixes, MIMETypes, writerClassName,
@@ -79,10 +79,10 @@ public class BMPImageWriterSpi
nativeImageMetadataFormatClassName, extraImageMetadataFormatNames,
extraImageMetadataFormatClassNames);
}
-
+
/**
* Returns true if the image can be encoded.
- *
+ *
* @param type - the image type specifier.
* @return true if image can be encoded, otherwise false.
*/
@@ -90,7 +90,7 @@ public class BMPImageWriterSpi
{
if (type == null)
return false;
-
+
BMPInfoHeader ih = writerInstance.infoHeader;
if (ih != null)
{
@@ -101,7 +101,7 @@ public class BMPImageWriterSpi
|| bytes != 4
|| bytes != 8
|| bytes != 16
- || bytes != 24
+ || bytes != 24
|| bytes != 32))))
return false;
}
@@ -110,7 +110,7 @@ public class BMPImageWriterSpi
/**
* Creates an instance of ImageWriter using the given extension.
- *
+ *
* @param extension - the provider that is constructing this image writer, or
* null
*/
@@ -122,7 +122,7 @@ public class BMPImageWriterSpi
writerInstance = new BMPImageWriter(this);
return writerInstance;
}
-
+
/**
* Gets the instance of ImageWriter, if already created.
*/
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
index a9f1ffda7e5..e14afdb04c3 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
@@ -49,7 +49,7 @@ import javax.imageio.ImageWriteParam;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
-public class BMPInfoHeader
+public class BMPInfoHeader
{
/** Size of the bitmap info header */
protected int biSize;
@@ -97,7 +97,7 @@ public class BMPInfoHeader
/**
* Creates the header from an input stream, which is not closed.
- *
+ *
* @param in - the image input stream
* @throws IOException if an I/O error occured.
* @throws BMPException if the header was invalid
@@ -126,10 +126,10 @@ public class BMPInfoHeader
biClrUsed = buf.getInt();
biClrImportant = buf.getInt();
}
-
+
/**
* Creates the info header from an output stream, which is not closed.
- *
+ *
* @param out - the image output stream
* @param im - the image
* @param param - the image write param.
@@ -139,12 +139,12 @@ public class BMPInfoHeader
{
RenderedImage img = im.getRenderedImage();
ColorModel cMod = img.getColorModel();
-
+
biSize = SIZE;
biWidth = img.getWidth();
biHeight = img.getHeight();
biPlanes = 1;
-
+
if (param != null && param.canWriteCompressed())
{
String compType = param.getCompressionType();
@@ -167,9 +167,9 @@ public class BMPInfoHeader
else
{
biBitCount = (short) cMod.getPixelSize();
- biCompression = BI_RGB;
+ biCompression = BI_RGB;
}
-
+
biXPelsPerMeter = 0x0;
biYPelsPerMeter = 0x0;
biClrUsed = 0;
@@ -188,13 +188,13 @@ public class BMPInfoHeader
out.write(intToDWord(biClrUsed));
out.write(intToDWord(biClrImportant));
}
-
+
/**
* Converts an int to a word, where the return value is stored in a
* 2-byte array.
- *
+ *
* @param val - the value to convert
- * @return the array
+ * @return the array
*/
private byte[] intToWord(int val)
{
@@ -207,9 +207,9 @@ public class BMPInfoHeader
/**
* Converts an int to a double word, where the return value is
* stored in a 4-byte array.
- *
+ *
* @param val - the value to convert
- * @return the array
+ * @return the array
*/
private byte[] intToDWord(int val)
{
@@ -221,7 +221,7 @@ public class BMPInfoHeader
return b;
}
-
+
public void setBitCount(short bitcount) throws BMPException
{
switch (bitcount)
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF16.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF16.java
index 397b857aa37..2f94ac6136b 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF16.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF16.java
@@ -54,49 +54,46 @@ public class DecodeBF16 extends BMPDecoder {
private int[] bitmasks;
private boolean useDefaultMasks;
- public DecodeBF16(BMPFileHeader fh, BMPInfoHeader ih,
- boolean udm){
- super(fh,ih);
+ public DecodeBF16(BMPFileHeader fh, BMPInfoHeader ih,
+ boolean udm){
+ super(fh,ih);
- useDefaultMasks = udm;
- if(useDefaultMasks) // 5-6-5 mask, B,G,R
- bitmasks = new int[] { 0x00F800, 0x0007E0, 0x00001F };
+ useDefaultMasks = udm;
+ if(useDefaultMasks) // 5-6-5 mask, B,G,R
+ bitmasks = new int[] { 0x00F800, 0x0007E0, 0x00001F };
}
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- if(!useDefaultMasks)
- bitmasks = readBitMasks(in);
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
-
- // BMP scanlines are padded to dword offsets
- int scansize = (w + (w&1)) << 1;
- short[] data = new short[w*h];
-
- for(int y=h-1;y>=0;y--){
- byte[] scanline = new byte[scansize];
- if(in.read(scanline) != scansize)
- throw new IOException("Couldn't read image data.");
-
- for(int x=0;x<w;x++)
- data[x + y*w] = (short)((scanline[x*2] & (0xFF)) |
- ((scanline[x*2+1] & (0xFF)) << 8));
- }
-
- ColorModel cm = new DirectColorModel(16,
- bitmasks[0], bitmasks[1], bitmasks[2]);
- SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
- w, h,
- bitmasks);
- DataBuffer db = new DataBufferUShort(data, w*h, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
- return new BufferedImage(cm, raster, false, null);
+ if(!useDefaultMasks)
+ bitmasks = readBitMasks(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = (w + (w&1)) << 1;
+ short[] data = new short[w*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = (short)((scanline[x*2] & (0xFF)) |
+ ((scanline[x*2+1] & (0xFF)) << 8));
+ }
+
+ ColorModel cm = new DirectColorModel(16,
+ bitmasks[0], bitmasks[1], bitmasks[2]);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
+ w, h,
+ bitmasks);
+ DataBuffer db = new DataBufferUShort(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+ return new BufferedImage(cm, raster, false, null);
}
}
-
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
index 47ce8cc76d2..bfa46948848 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
@@ -54,53 +54,50 @@ public class DecodeBF32 extends BMPDecoder {
private int[] bitmasks;
private boolean useDefaultMasks;
- public DecodeBF32(BMPFileHeader fh, BMPInfoHeader ih,
- boolean udm){
- super(fh,ih);
+ public DecodeBF32(BMPFileHeader fh, BMPInfoHeader ih,
+ boolean udm){
+ super(fh,ih);
- useDefaultMasks = udm;
- if(useDefaultMasks)
- bitmasks = new int[] { 0x00FF0000, 0x0000FF00, 0x000000FF };
+ useDefaultMasks = udm;
+ if(useDefaultMasks)
+ bitmasks = new int[] { 0x00FF0000, 0x0000FF00, 0x000000FF };
}
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- if(!useDefaultMasks)
- bitmasks = readBitMasks(in);
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
-
- // BMP scanlines are padded to dword offsets
- int scansize = w << 2;
- int[] data = new int[w*h];
-
-
- for(int y=h-1;y>=0;y--){
- byte[] scanline = new byte[scansize];
- if(in.read(scanline) != scansize)
- throw new IOException("Couldn't read image data.");
-
- for(int x=0;x<w;x++)
- data[x + y*w] = ((scanline[x<<2] & (0xFF)) |
- ((scanline[(x<<2)+1] & (0xFF)) << 8) |
- ((scanline[(x<<2)+2] & (0xFF)) << 16) |
- ((scanline[(x<<2)+3] & (0xFF)) << 24));
- }
-
- ColorModel cm = new DirectColorModel(32,
- bitmasks[0], bitmasks[1], bitmasks[2]);
- SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
- w, h,
- bitmasks);
- DataBuffer db = new DataBufferInt(data, w*h);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(cm, raster, false, null);
+ if(!useDefaultMasks)
+ bitmasks = readBitMasks(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = w << 2;
+ int[] data = new int[w*h];
+
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = ((scanline[x<<2] & (0xFF)) |
+ ((scanline[(x<<2)+1] & (0xFF)) << 8) |
+ ((scanline[(x<<2)+2] & (0xFF)) << 16) |
+ ((scanline[(x<<2)+3] & (0xFF)) << 24));
+ }
+
+ ColorModel cm = new DirectColorModel(32,
+ bitmasks[0], bitmasks[1], bitmasks[2]);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
+ w, h,
+ bitmasks);
+ DataBuffer db = new DataBufferInt(data, w*h);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(cm, raster, false, null);
}
}
-
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB1.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB1.java
index 9ca82d9ee4a..ca81bc43336 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB1.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB1.java
@@ -52,45 +52,43 @@ import java.awt.Dimension;
public class DecodeRGB1 extends BMPDecoder {
public DecodeRGB1(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
- public BufferedImage decode(ImageInputStream in)
- throws IOException, BMPException {
+ public BufferedImage decode(ImageInputStream in)
+ throws IOException, BMPException {
- IndexColorModel palette = readPalette(in);
- skipToImage(in);
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
- int size = (w*h)>>3;
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ int size = (w*h)>>3;
- int scansize = w>>3;
- byte[] data = new byte[size];
+ int scansize = w>>3;
+ byte[] data = new byte[size];
- for(int y=h-1;y>=0;y--){
- // Scanlines are padded to dword boundries
- int readsize = scansize;
- if((readsize & 3) != 0) readsize += (4 - (scansize & 3));
+ for(int y=h-1;y>=0;y--){
+ // Scanlines are padded to dword boundries
+ int readsize = scansize;
+ if((readsize & 3) != 0) readsize += (4 - (scansize & 3));
- byte[] scanline = new byte[readsize];
- if(in.read(scanline) != readsize)
- throw new IOException("Couldn't read image data.");
+ byte[] scanline = new byte[readsize];
+ if(in.read(scanline) != readsize)
+ throw new IOException("Couldn't read image data.");
- for(int x=0;x<scansize;x++)
- data[x + y*scansize] = scanline[x];
- }
+ for(int x=0;x<scansize;x++)
+ data[x + y*scansize] = scanline[x];
+ }
- SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
- w, h, 1);
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 1);
- DataBuffer db = new DataBufferByte(data, size, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(palette, raster, false, null);
+ DataBuffer db = new DataBufferByte(data, size, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
}
}
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
index 2b7f99be169..0ddcc434ed3 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
@@ -45,33 +45,33 @@ import java.awt.Dimension;
public class DecodeRGB24 extends BMPDecoder {
public DecodeRGB24(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
- BufferedImage image = new BufferedImage(w, h,
- BufferedImage.TYPE_INT_RGB);
- // BMP scanlines are padded to dword offsets
- int scansize = ((w*3 & 3) != 0)? w*3 + 4 - (w*3 & 3): w*3;
- int[] data = new int[w*h];
+ skipToImage(in);
- for(int y=h-1;y>=0;y--){
- byte[] scanline = new byte[scansize];
- if(in.read(scanline) != scansize)
- throw new IOException("Couldn't read image data.");
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_RGB);
+ // BMP scanlines are padded to dword offsets
+ int scansize = ((w*3 & 3) != 0)? w*3 + 4 - (w*3 & 3): w*3;
+ int[] data = new int[w*h];
- for(int x=0;x<w;x++)
- data[x + y*w] = scanline[x*3] +
- (scanline[x*3+1] << 8) +
- (scanline[x*3+2] << 16);
- }
- image.setRGB(0, 0, w, h, data, 0, w);
- return image;
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = scanline[x*3] +
+ (scanline[x*3+1] << 8) +
+ (scanline[x*3+2] << 16);
+ }
+ image.setRGB(0, 0, w, h, data, 0, w);
+ return image;
}
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB4.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB4.java
index a10d390ab82..a904ef74575 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB4.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB4.java
@@ -52,41 +52,39 @@ import java.awt.Dimension;
public class DecodeRGB4 extends BMPDecoder {
public DecodeRGB4(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- IndexColorModel palette = readPalette(in);
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
- int size = (w*h) >> 1;
-
- // Scanline padded to dword offsets
- int wbytes = (w + (w & 1)) >> 1;
- int scansize = ((wbytes & 3) != 0)? (wbytes + 4 - (wbytes&3)) : wbytes;
-
- byte[] data = new byte[wbytes*h];
-
- for(int y=h-1;y>=0;y--){
- byte[] scanline = new byte[scansize];
- if(in.read(scanline) != scansize)
- throw new IOException("Couldn't read image data.");
-
- for(int x=0;x<wbytes;x++)
- data[x + y*wbytes] = scanline[x];
- }
- SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
- w, h, 4);
-
- DataBuffer db = new DataBufferByte(data, w*h, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(palette, raster, false, null);
- }
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
-}
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ int size = (w*h) >> 1;
+
+ // Scanline padded to dword offsets
+ int wbytes = (w + (w & 1)) >> 1;
+ int scansize = ((wbytes & 3) != 0)? (wbytes + 4 - (wbytes&3)) : wbytes;
+
+ byte[] data = new byte[wbytes*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+ for(int x=0;x<wbytes;x++)
+ data[x + y*wbytes] = scanline[x];
+ }
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 4);
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB8.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB8.java
index dfe4a19e8be..218047e5da7 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB8.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB8.java
@@ -52,39 +52,37 @@ import java.awt.Dimension;
public class DecodeRGB8 extends BMPDecoder {
public DecodeRGB8(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- IndexColorModel palette = readPalette(in);
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
-
- // BMP scanlines are padded to dword offsets
- int scansize = ((w & 3) != 0)? w + 4 - (w & 3): w;
- byte[] data = new byte[w*h];
-
- for(int y=h-1;y>=0;y--){
- byte[] scanline = new byte[scansize];
- if(in.read(scanline) != scansize)
- throw new IOException("Couldn't read image data.");
-
- for(int x=0;x<w;x++)
- data[x + y*w] = scanline[x];
- }
-
- SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
- w, h,
- new int[] {0xFF});
- DataBuffer db = new DataBufferByte(data, w*h, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(palette, raster, false, null);
- }
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
-}
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = ((w & 3) != 0)? w + 4 - (w & 3): w;
+ byte[] data = new byte[w*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+ for(int x=0;x<w;x++)
+ data[x + y*w] = scanline[x];
+ }
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h,
+ new int[] {0xFF});
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE4.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE4.java
index 55d314f05f1..1c116c2473c 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE4.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE4.java
@@ -52,7 +52,7 @@ import java.awt.Dimension;
public class DecodeRLE4 extends BMPDecoder {
public DecodeRLE4(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
/**
@@ -62,115 +62,114 @@ public class DecodeRLE4 extends BMPDecoder {
private static final byte EOL = (byte)0; // end of line
private static final byte EOB = (byte)1; // end of bitmap
private static final byte DELTA = (byte)2; // delta
-
+
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- IndexColorModel palette = readPalette(in);
- skipToImage(in);
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
+ byte[] data = uncompress(w, h, in);
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 4);
- byte[] data = uncompress(w, h, in);
- SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
- w, h, 4);
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
- DataBuffer db = new DataBufferByte(data, w*h, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(palette, raster, false, null);
+ return new BufferedImage(palette, raster, false, null);
}
-
- private byte[] uncompress(int w, int h, ImageInputStream in)
- throws BMPException, IOException {
- byte[] cmd = new byte[2];
- byte[] data = new byte[w*h>>1];
- int offIn = 0;
- int x=0,y=0;
-
- // width in bytes
- w += (w&1);
- w = w >> 1;
-
- try {
- while(((x>>1) + y*w) < w*h){
- if(in.read(cmd) != 2)
- throw new IOException("Error reading compressed data.");
-
- if(cmd[0] == ESCAPE){
- switch(cmd[1]){
- case EOB: // end of bitmap
- return data;
- case EOL: // end of line
- x = 0;
- y++;
- break;
- case DELTA: // delta
- if(in.read(cmd) != 2)
- throw new IOException("Error reading compressed data.");
- int dx = cmd[0] & (0xFF);
- int dy = cmd[1] & (0xFF);
- x += dx;
- y += dy;
- break;
-
- default:
- // decode a literal run
- int length = cmd[1] & (0xFF);
-
- // size of run, which is word aligned.
- int bytesize = length;
- bytesize += (bytesize & 1);
- bytesize >>= 1;
- bytesize += (bytesize & 1);
-
- byte[] run = new byte[bytesize];
- if(in.read(run) != bytesize)
- throw new IOException("Error reading compressed data.");
-
- if((x&1) == 0){
- length += (length&1);
- length >>= 1;
- System.arraycopy(run, 0, data, ((x>>1) + w*(h-y-1)),
- length);
- } else {
- for(int i=0;i<length;i++){
- if((i&1) == 0) // copy high to low
- data[((x+i)>>1) + w*(h-y-1)]
- |= ((run[i>>1]&0xF0) >> 4);
- else // copy low to high
- data[((x+i)>>1) + w*(h-y-1)]
- |= ((run[i>>1]&0x0F) << 4);
- }
- }
- x += cmd[1] & (0xFF);
- break;
- }
- } else {
- // decode a byte run
- int length = cmd[0] & (0xFF);
- if((x&1) == 0){
- length += (length&1);
- length >>= 1;
- for(int i=0;i<length;i++)
- data[(h-y-1)*w + i + (x >> 1)] = cmd[1];
- } else {
- for(int i=0;i<length;i++){
- if((i&1) == 0) // copy high to low
- data[((x+i)>>1) + w*(h-y-1)]
- |= ((cmd[1]&0xF0) >> 4);
- else // copy low to high
- data[((x+i)>>1) + w*(h-y-1)]
- |= ((cmd[1]&0x0F) << 4);
- }
- }
- x += cmd[0] & (0xFF);
- }
- }
- return data;
- } catch(ArrayIndexOutOfBoundsException e){
- throw new BMPException("Invalid RLE data.");
- }
+
+ private byte[] uncompress(int w, int h, ImageInputStream in)
+ throws BMPException, IOException {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w*h>>1];
+ int offIn = 0;
+ int x=0,y=0;
+
+ // width in bytes
+ w += (w&1);
+ w = w >> 1;
+
+ try {
+ while(((x>>1) + y*w) < w*h){
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+
+ if(cmd[0] == ESCAPE){
+ switch(cmd[1]){
+ case EOB: // end of bitmap
+ return data;
+ case EOL: // end of line
+ x = 0;
+ y++;
+ break;
+ case DELTA: // delta
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ // decode a literal run
+ int length = cmd[1] & (0xFF);
+
+ // size of run, which is word aligned.
+ int bytesize = length;
+ bytesize += (bytesize & 1);
+ bytesize >>= 1;
+ bytesize += (bytesize & 1);
+
+ byte[] run = new byte[bytesize];
+ if(in.read(run) != bytesize)
+ throw new IOException("Error reading compressed data.");
+
+ if((x&1) == 0){
+ length += (length&1);
+ length >>= 1;
+ System.arraycopy(run, 0, data, ((x>>1) + w*(h-y-1)),
+ length);
+ } else {
+ for(int i=0;i<length;i++){
+ if((i&1) == 0) // copy high to low
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((run[i>>1]&0xF0) >> 4);
+ else // copy low to high
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((run[i>>1]&0x0F) << 4);
+ }
+ }
+ x += cmd[1] & (0xFF);
+ break;
+ }
+ } else {
+ // decode a byte run
+ int length = cmd[0] & (0xFF);
+ if((x&1) == 0){
+ length += (length&1);
+ length >>= 1;
+ for(int i=0;i<length;i++)
+ data[(h-y-1)*w + i + (x >> 1)] = cmd[1];
+ } else {
+ for(int i=0;i<length;i++){
+ if((i&1) == 0) // copy high to low
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((cmd[1]&0xF0) >> 4);
+ else // copy low to high
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((cmd[1]&0x0F) << 4);
+ }
+ }
+ x += cmd[0] & (0xFF);
+ }
+ }
+ return data;
+ } catch(ArrayIndexOutOfBoundsException e){
+ throw new BMPException("Invalid RLE data.");
+ }
}
}
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE8.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE8.java
index 1d00e6751d0..afc3da89efc 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE8.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRLE8.java
@@ -52,7 +52,7 @@ import java.awt.Dimension;
public class DecodeRLE8 extends BMPDecoder {
public DecodeRLE8(BMPFileHeader fh, BMPInfoHeader ih){
- super(fh, ih);
+ super(fh, ih);
}
/**
@@ -62,82 +62,81 @@ public class DecodeRLE8 extends BMPDecoder {
private static final byte EOL = (byte)0; // end of line
private static final byte EOB = (byte)1; // end of bitmap
private static final byte DELTA = (byte)2; // delta
-
+
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
- IndexColorModel palette = readPalette(in);
- skipToImage(in);
-
- Dimension d = infoHeader.getSize();
- int h = (int)d.getHeight();
- int w = (int)d.getWidth();
-
- byte[] data = uncompress(w, h, in);
- SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
- w, h,
- new int[] {0xFF});
- DataBuffer db = new DataBufferByte(data, w*h, 0);
- WritableRaster raster = Raster.createWritableRaster(sm, db, null);
-
- return new BufferedImage(palette, raster, false, null);
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ byte[] data = uncompress(w, h, in);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h,
+ new int[] {0xFF});
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
}
-
- private byte[] uncompress(int w, int h, ImageInputStream in)
- throws BMPException, IOException {
- byte[] cmd = new byte[2];
- byte[] data = new byte[w*h];
- int offIn = 0;
- int x=0,y=0;
-
- try {
- while((x + y*w) < w*h){
- if(in.read(cmd) != 2)
- throw new IOException("Error reading compressed data.");
-
- if(cmd[0] == ESCAPE){
- switch(cmd[1]){
- case EOB: // end of bitmap
- return data;
- case EOL: // end of line
- x = 0;
- y++;
- break;
- case DELTA: // delta
- if(in.read(cmd) != 2)
- throw new IOException("Error reading compressed data.");
- int dx = cmd[0] & (0xFF);
- int dy = cmd[1] & (0xFF);
- x += dx;
- y += dy;
- break;
-
- default:
- // decode a literal run
- int length = cmd[1] & (0xFF);
- int copylength = length;
-
- // absolute mode must be word-aligned
- length += (length & 1);
-
- byte[] run = new byte[length];
- if(in.read(run) != length)
- throw new IOException("Error reading compressed data.");
-
- System.arraycopy(run, 0, data, (x+w*(h-y-1)),
- copylength);
- x += copylength;
- break;
- }
- } else {
- // decode a byte run
- int length = cmd[0] & (0xFF);
- for(int i=0;i<length;i++)
- data[(h-y-1)*w + x++] = cmd[1];
- }
- }
- return data;
- } catch(ArrayIndexOutOfBoundsException e){
- throw new BMPException("Invalid RLE data.");
- }
+
+ private byte[] uncompress(int w, int h, ImageInputStream in)
+ throws BMPException, IOException {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w*h];
+ int offIn = 0;
+ int x=0,y=0;
+
+ try {
+ while((x + y*w) < w*h){
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+
+ if(cmd[0] == ESCAPE){
+ switch(cmd[1]){
+ case EOB: // end of bitmap
+ return data;
+ case EOL: // end of line
+ x = 0;
+ y++;
+ break;
+ case DELTA: // delta
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ // decode a literal run
+ int length = cmd[1] & (0xFF);
+ int copylength = length;
+
+ // absolute mode must be word-aligned
+ length += (length & 1);
+
+ byte[] run = new byte[length];
+ if(in.read(run) != length)
+ throw new IOException("Error reading compressed data.");
+
+ System.arraycopy(run, 0, data, (x+w*(h-y-1)),
+ copylength);
+ x += copylength;
+ break;
+ }
+ } else {
+ // decode a byte run
+ int length = cmd[0] & (0xFF);
+ for(int i=0;i<length;i++)
+ data[(h-y-1)*w + x++] = cmd[1];
+ }
+ }
+ return data;
+ } catch(ArrayIndexOutOfBoundsException e){
+ throw new BMPException("Invalid RLE data.");
+ }
}
}
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java
index 293aba8102d..ffe671dc0b3 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java
@@ -56,7 +56,7 @@ public class EncodeRGB1
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -70,7 +70,7 @@ public class EncodeRGB1
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -101,13 +101,13 @@ public class EncodeRGB1
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
rgb[0] = (byte) (value & 0xFF);
-
+
o.write(rgb);
if (rowCount == infoHeader.biWidth)
{
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java
index 3e9912855b1..a5450cc674b 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java
@@ -1,4 +1,4 @@
-/* EncodeRGB16.java --
+/* EncodeRGB16.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,7 +56,7 @@ public class EncodeRGB16
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -67,10 +67,10 @@ public class EncodeRGB16
infoHeader = ih;
offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -101,14 +101,14 @@ public class EncodeRGB16
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
rgb[0] = (byte) (value & 0xFF);
rgb[1] = (byte) (value >> 8 & 0xFF);
-
+
o.write(rgb);
if (rowCount == infoHeader.biWidth)
{
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java
index 10c1abee8a3..7fbc83e2e26 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java
@@ -56,7 +56,7 @@ public class EncodeRGB24
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -67,10 +67,10 @@ public class EncodeRGB24
infoHeader = ih;
offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -101,7 +101,7 @@ public class EncodeRGB24
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java
index 4aa1cd5d2fb..7deca30491e 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java
@@ -1,4 +1,4 @@
-/* EncodeRGB32.java --
+/* EncodeRGB32.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,7 +56,7 @@ public class EncodeRGB32
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -67,10 +67,10 @@ public class EncodeRGB32
infoHeader = ih;
offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or null
* @param image - an IIOImage containing image data.
@@ -100,7 +100,7 @@ public class EncodeRGB32
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java
index f1903541f7c..b62283a7d42 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java
@@ -56,7 +56,7 @@ public class EncodeRGB4
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -70,7 +70,7 @@ public class EncodeRGB4
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -101,13 +101,13 @@ public class EncodeRGB4
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
rgb[0] = (byte) (value & 0xFF);
-
+
o.write(rgb);
if (rowCount == infoHeader.biWidth)
{
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
index dd7387a9a17..ef0594a5f56 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
@@ -56,7 +56,7 @@ public class EncodeRGB8
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -70,7 +70,7 @@ public class EncodeRGB8
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -101,7 +101,7 @@ public class EncodeRGB8
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
index 3674c4d7877..c54c3ca8710 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
@@ -1,4 +1,4 @@
-/* EncodeRLE4.java --
+/* EncodeRLE4.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,10 +63,10 @@ public class EncodeRLE4
private static final byte EOL = (byte)0; // end of line
private static final byte EOB = (byte)1; // end of bitmap
private static final byte DELTA = (byte)2; // delta
-
+
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -77,10 +77,10 @@ public class EncodeRLE4
infoHeader = ih;
offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -111,12 +111,12 @@ public class EncodeRLE4
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
buf.put((byte) (value & 0xFF));
-
+
if (rowCount == infoHeader.biWidth)
{
rowCount = 1;
@@ -127,7 +127,7 @@ public class EncodeRLE4
rowCount++;
rowIndex++;
}
-
+
buf.flip();
o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
}
@@ -136,10 +136,10 @@ public class EncodeRLE4
wb.printStackTrace();
}
}
-
+
/**
* Uncompresses the image stored in the buffer.
- *
+ *
* @param w - the width of the image
* @param h - the height of the image
* @param buf - the ByteBuffer containing the pixel values.
@@ -190,7 +190,7 @@ public class EncodeRLE4
{
throw new IOException("Error reading compressed data.");
}
-
+
int dx = cmd[0] & (0xFF);
int dy = cmd[1] & (0xFF);
x += dx;
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
index dbbaeb26996..62277ef90d2 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
@@ -1,4 +1,4 @@
-/* EncodeRGB32.java --
+/* EncodeRGB32.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ public class EncodeRLE8
protected BMPInfoHeader infoHeader;
protected BMPFileHeader fileHeader;
protected long offset;
-
+
/**
* RLE control codes
*/
@@ -66,7 +66,7 @@ public class EncodeRLE8
/**
* Constructs an instance of this class.
- *
+ *
* @param fh - the file header to use.
* @param ih - the info header to use.
*/
@@ -77,10 +77,10 @@ public class EncodeRLE8
infoHeader = ih;
offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
}
-
+
/**
* The image encoder.
- *
+ *
* @param o - the image output stream
* @param streamMetadata - metadata associated with this stream, or
* null
@@ -111,12 +111,12 @@ public class EncodeRLE8
infoHeader.biHeight, bitmap, 0,
infoHeader.biWidth);
pg.grabPixels();
-
+
for (j = 0; j < size; j++)
{
value = bitmap[rowIndex];
buf.put((byte) (value & 0xFF));
-
+
if (rowCount == infoHeader.biWidth)
{
rowCount = 1;
@@ -127,7 +127,7 @@ public class EncodeRLE8
rowCount++;
rowIndex++;
}
-
+
buf.flip();
o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
}
@@ -136,11 +136,11 @@ public class EncodeRLE8
wb.printStackTrace();
}
}
-
+
/**
* Uncompresses the image stored in the buffer.
- *
+ *
* @param w - the width of the image
* @param h - the height of the image
* @param buf - the ByteBuffer containing the pixel values.
@@ -187,7 +187,7 @@ public class EncodeRLE8
{
throw new IOException("Error reading compressed data.");
}
-
+
int dx = cmd[0] & (0xFF);
int dy = cmd[1] & (0xFF);
x += dx;