mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-01 00:00:02 -04:00
Fixed JavaDoc errors to enable Java 8 build.
(cherry picked from commit 9e23413456)
This commit is contained in:
-1
@@ -38,7 +38,6 @@ import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Abstract base class for RLE decoding as specified by in the Windows BMP (aka DIB) file format.
|
||||
* <p/>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: AbstractRLEDecoder.java#1 $
|
||||
|
||||
+2
-38
@@ -214,11 +214,9 @@ public final class BMPImageReader extends ImageReaderBase {
|
||||
|
||||
case 16:
|
||||
if (header.hasMasks()) {
|
||||
int[] masks = getMasks();
|
||||
|
||||
return ImageTypeSpecifiers.createPacked(
|
||||
ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
masks[0], masks[1], masks[2], masks[3],
|
||||
header.masks[0], header.masks[1], header.masks[2], header.masks[3],
|
||||
DataBuffer.TYPE_USHORT, false
|
||||
);
|
||||
}
|
||||
@@ -235,11 +233,9 @@ public final class BMPImageReader extends ImageReaderBase {
|
||||
|
||||
case 32:
|
||||
if (header.hasMasks()) {
|
||||
int[] masks = getMasks();
|
||||
|
||||
return ImageTypeSpecifiers.createPacked(
|
||||
ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
masks[0], masks[1], masks[2], masks[3],
|
||||
header.masks[0], header.masks[1], header.masks[2], header.masks[3],
|
||||
DataBuffer.TYPE_INT, false
|
||||
);
|
||||
}
|
||||
@@ -256,38 +252,6 @@ public final class BMPImageReader extends ImageReaderBase {
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getMasks() throws IOException {
|
||||
if (header.masks != null) {
|
||||
// Get mask and create either 555, 565 or 444/4444 etc
|
||||
return header.masks;
|
||||
}
|
||||
|
||||
switch (header.getCompression()) {
|
||||
case DIB.COMPRESSION_BITFIELDS:
|
||||
case DIB.COMPRESSION_ALPHA_BITFIELDS:
|
||||
// Consult BITFIELDS/ALPHA_BITFIELDS
|
||||
return readBitFieldsMasks();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int[] readBitFieldsMasks() throws IOException {
|
||||
long offset = DIB.BMP_FILE_HEADER_SIZE + header.getSize();
|
||||
|
||||
if (offset != imageInput.getStreamPosition()) {
|
||||
imageInput.seek(offset);
|
||||
}
|
||||
|
||||
int[] masks = DIBHeader.readMasks(imageInput);
|
||||
|
||||
if (header.getCompression() != DIB.COMPRESSION_ALPHA_BITFIELDS) {
|
||||
masks[3] = 0;
|
||||
}
|
||||
|
||||
return masks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException {
|
||||
checkBounds(imageIndex);
|
||||
|
||||
+48
-71
@@ -4,32 +4,35 @@
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name "TwelveMonkeys" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package com.twelvemonkeys.imageio.plugins.bmp;
|
||||
|
||||
import javax.imageio.IIOException;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -104,17 +107,15 @@ abstract class DIBHeader {
|
||||
case DIB.OS2_V2_HEADER_SIZE:
|
||||
return new BitmapCoreHeaderV2();
|
||||
case DIB.BITMAP_INFO_HEADER_SIZE:
|
||||
case DIB.BITMAP_V2_INFO_HEADER_SIZE:
|
||||
case DIB.BITMAP_V3_INFO_HEADER_SIZE:
|
||||
// ICO and CUR always uses the Microsoft Windows 3.0 DIB header, which is 40 bytes.
|
||||
// This is also the most common format for persistent BMPs.
|
||||
return new BitmapInfoHeader();
|
||||
case DIB.BITMAP_V3_INFO_HEADER_SIZE:
|
||||
return new BitmapV3InfoHeader();
|
||||
case DIB.BITMAP_V4_INFO_HEADER_SIZE:
|
||||
return new BitmapV4InfoHeader();
|
||||
case DIB.BITMAP_V5_INFO_HEADER_SIZE:
|
||||
return new BitmapV5InfoHeader();
|
||||
case DIB.BITMAP_V2_INFO_HEADER_SIZE:
|
||||
throw new IIOException(String.format("Windows Bitmap Information Header (size: %s) not supported", pSize));
|
||||
default:
|
||||
throw new IIOException(String.format("Unknown Bitmap Information Header (size: %s)", pSize));
|
||||
}
|
||||
@@ -159,7 +160,7 @@ abstract class DIBHeader {
|
||||
}
|
||||
|
||||
public int getColorsUsed() {
|
||||
return colorsUsed != 0 ? colorsUsed : 1 << bitCount;
|
||||
return colorsUsed != 0 ? colorsUsed : 1 << Math.min(24, bitCount);
|
||||
}
|
||||
|
||||
public int getColorsImportant() {
|
||||
@@ -187,9 +188,11 @@ abstract class DIBHeader {
|
||||
);
|
||||
}
|
||||
|
||||
static int[] readMasks(final DataInput pStream) throws IOException {
|
||||
private static int[] readMasks(final DataInput pStream, final boolean hasAlphaMask) throws IOException {
|
||||
int maskCount = hasAlphaMask ? 4 : 3;
|
||||
int[] masks = new int[4];
|
||||
for (int i = 0; i < masks.length; i++) {
|
||||
|
||||
for (int i = 0; i < maskCount; i++) {
|
||||
masks[i] = pStream.readInt();
|
||||
}
|
||||
|
||||
@@ -228,10 +231,11 @@ abstract class DIBHeader {
|
||||
|
||||
/**
|
||||
* OS/2 BitmapCoreHeader Version 2.
|
||||
* <p/>
|
||||
* <p>
|
||||
* NOTE: According to the docs this header is <em>variable size</em>.
|
||||
* However, it seems that the size is either 16, 40 or 64, which is covered
|
||||
* (40 is the size of the normal {@link BitmapInfoHeader}, and has the same layout).
|
||||
* </p>
|
||||
*
|
||||
* @see <a href="http://www.fileformat.info/format/os2bmp/egff.htm">OS/2 Bitmap File Format Summary</a>
|
||||
*/
|
||||
@@ -287,15 +291,19 @@ abstract class DIBHeader {
|
||||
* Represents the DIB (Device Independent Bitmap) Windows 3.0 Bitmap Information header structure.
|
||||
* This is the common format for persistent DIB structures, even if Windows
|
||||
* may use the later versions at run-time.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Note: Some variations that includes the mask fields into the header size exists,
|
||||
* but is no longer part of the documented spec.
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: DIBHeader.java,v 1.0 25.feb.2006 00:29:44 haku Exp$
|
||||
* @see <a href="http://en.wikipedia.org/wiki/BMP_file_format">BMP file format (Wikipedia)</a>
|
||||
* @see <a href="https://forums.adobe.com/message/3272950#3272950">BITMAPV3INFOHEADER</a>.
|
||||
*/
|
||||
static final class BitmapInfoHeader extends DIBHeader {
|
||||
protected void read(final int pSize, final DataInput pStream) throws IOException {
|
||||
if (pSize != DIB.BITMAP_INFO_HEADER_SIZE) {
|
||||
if (!(pSize == DIB.BITMAP_INFO_HEADER_SIZE || pSize == DIB.BITMAP_V2_INFO_HEADER_SIZE || pSize == DIB.BITMAP_V3_INFO_HEADER_SIZE)) {
|
||||
throw new IIOException(String.format("Size: %s !=: %s", pSize, DIB.BITMAP_INFO_HEADER_SIZE));
|
||||
}
|
||||
|
||||
@@ -320,6 +328,15 @@ abstract class DIBHeader {
|
||||
|
||||
colorsUsed = pStream.readInt();
|
||||
colorsImportant = pStream.readInt();
|
||||
|
||||
// Read masks if we have V2 or V3
|
||||
// or if we have compression BITFIELDS or ALPHA_BITFIELDS
|
||||
if (size == DIB.BITMAP_V2_INFO_HEADER_SIZE || compression == DIB.COMPRESSION_BITFIELDS) {
|
||||
masks = readMasks(pStream, false);
|
||||
}
|
||||
else if (size == DIB.BITMAP_V3_INFO_HEADER_SIZE || compression == DIB.COMPRESSION_ALPHA_BITFIELDS) {
|
||||
masks = readMasks(pStream, true);
|
||||
}
|
||||
}
|
||||
|
||||
public String getBMPVersion() {
|
||||
@@ -328,46 +345,6 @@ abstract class DIBHeader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the semi-undocumented structure BITMAPV3INFOHEADER.
|
||||
* @see <a href="https://forums.adobe.com/message/3272950#3272950">BITMAPV3INFOHEADER</a>
|
||||
*/
|
||||
static final class BitmapV3InfoHeader extends DIBHeader {
|
||||
protected void read(final int pSize, final DataInput pStream) throws IOException {
|
||||
if (pSize != DIB.BITMAP_V3_INFO_HEADER_SIZE) {
|
||||
throw new IIOException(String.format("Size: %s !=: %s", pSize, DIB.BITMAP_V3_INFO_HEADER_SIZE));
|
||||
}
|
||||
|
||||
size = pSize;
|
||||
|
||||
width = pStream.readInt();
|
||||
height = pStream.readInt();
|
||||
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
topDown = true;
|
||||
}
|
||||
|
||||
planes = pStream.readUnsignedShort();
|
||||
bitCount = pStream.readUnsignedShort();
|
||||
compression = pStream.readInt();
|
||||
|
||||
imageSize = pStream.readInt();
|
||||
|
||||
xPixelsPerMeter = pStream.readInt();
|
||||
yPixelsPerMeter = pStream.readInt();
|
||||
|
||||
colorsUsed = pStream.readInt();
|
||||
colorsImportant = pStream.readInt();
|
||||
|
||||
masks = readMasks(pStream);
|
||||
}
|
||||
|
||||
public String getBMPVersion() {
|
||||
return "BMP v. 3.x Photoshop";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the BITMAPV4INFOHEADER structure.
|
||||
*/
|
||||
@@ -399,7 +376,7 @@ abstract class DIBHeader {
|
||||
colorsUsed = pStream.readInt();
|
||||
colorsImportant = pStream.readInt();
|
||||
|
||||
masks = readMasks(pStream);
|
||||
masks = readMasks(pStream, true);
|
||||
|
||||
colorSpaceType = pStream.readInt(); // Should be 0 for V4
|
||||
cieXYZEndpoints = new double[9];
|
||||
@@ -451,7 +428,7 @@ abstract class DIBHeader {
|
||||
colorsUsed = pStream.readInt();
|
||||
colorsImportant = pStream.readInt();
|
||||
|
||||
masks = readMasks(pStream);
|
||||
masks = readMasks(pStream, true);
|
||||
|
||||
colorSpaceType = pStream.readInt();
|
||||
|
||||
|
||||
+1
-2
@@ -47,14 +47,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ImageReader for Microsoft Windows ICO (icon) format.
|
||||
* 1, 4, 8 bit palette support with bitmask transparency, and 16, 24 and 32 bit
|
||||
* true color support with alpha. Also supports Windows Vista PNG encoded icons.
|
||||
* <p/>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: ICOImageReader.java,v 1.0 25.feb.2006 00:29:44 haku Exp$
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Directory
|
||||
* <p/>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: Directory.java,v 1.0 25.feb.2006 00:29:44 haku Exp$
|
||||
|
||||
-1
@@ -35,7 +35,6 @@ import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Implements 4 bit RLE decoding as specified by in the Windows BMP (aka DIB) file format.
|
||||
* <p/>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: RLE4Decoder.java#1 $
|
||||
|
||||
-1
@@ -34,7 +34,6 @@ import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Implements 8 bit RLE decoding as specified by in the Windows BMP (aka DIB) file format.
|
||||
* <p/>
|
||||
*
|
||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||
* @version $Id: RLE8Decoder.java#1 $
|
||||
|
||||
Reference in New Issue
Block a user