mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
#400 Fixed AIOOBE reading index color w/bitplanes for uneven widths.
This commit is contained in:
parent
63830a26e5
commit
cdb2d72f8b
@ -185,16 +185,16 @@ public final class PCXImageReader extends ImageReaderBase {
|
|||||||
if (rawType.getColorModel() instanceof IndexColorModel && header.getChannels() > 1) {
|
if (rawType.getColorModel() instanceof IndexColorModel && header.getChannels() > 1) {
|
||||||
// Bit planes!
|
// Bit planes!
|
||||||
// Create raster from a default 8 bit layout
|
// Create raster from a default 8 bit layout
|
||||||
WritableRaster rowRaster = GRAYSCALE.createBufferedImage(header.getWidth(), 1).getRaster();
|
int planeWidth = header.getBytesPerLine();
|
||||||
|
int rowWidth = planeWidth * 8; // bitsPerPixel == 1
|
||||||
|
WritableRaster rowRaster = GRAYSCALE.createBufferedImage(rowWidth, 1).getRaster();
|
||||||
|
|
||||||
// Clip to source region
|
// Clip to source region
|
||||||
Raster clippedRow = clipRowToRect(rowRaster, srcRegion,
|
Raster clippedRow = clipRowToRect(rowRaster, srcRegion,
|
||||||
param != null ? param.getSourceBands() : null,
|
param != null ? param.getSourceBands() : null,
|
||||||
param != null ? param.getSourceXSubsampling() : 1);
|
param != null ? param.getSourceXSubsampling() : 1);
|
||||||
|
|
||||||
int planeWidth = header.getBytesPerLine();
|
byte[] planeData = new byte[rowWidth];
|
||||||
byte[] planeData = new byte[planeWidth * 8];
|
|
||||||
|
|
||||||
byte[] rowDataByte = ((DataBufferByte) rowRaster.getDataBuffer()).getData();
|
byte[] rowDataByte = ((DataBufferByte) rowRaster.getDataBuffer()).getData();
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
@ -351,6 +351,7 @@ public final class PCXImageReader extends ImageReaderBase {
|
|||||||
if (header == null) {
|
if (header == null) {
|
||||||
imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN);
|
imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN);
|
||||||
header = PCXHeader.read(imageInput);
|
header = PCXHeader.read(imageInput);
|
||||||
|
// System.err.println("header: " + header);
|
||||||
imageInput.flushBefore(imageInput.getStreamPosition());
|
imageInput.flushBefore(imageInput.getStreamPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class PCXImageReaderTest extends ImageReaderAbstractTest<PCXImageReader>
|
|||||||
protected List<TestData> getTestData() {
|
protected List<TestData> getTestData() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new TestData(getClassLoaderResource("/pcx/MARBLES.PCX"), new Dimension(1419, 1001)), // RLE encoded RGB
|
new TestData(getClassLoaderResource("/pcx/MARBLES.PCX"), new Dimension(1419, 1001)), // RLE encoded RGB
|
||||||
// new TestData(getClassLoaderResource("/pcx/GMARBLES.PCX"), new Dimension(1419, 1001)) // RLE encoded gray (seems to be damanged, missing the last few scan lines)
|
// new TestData(getClassLoaderResource("/pcx/GMARBLES.PCX"), new Dimension(1419, 1001)) // RLE encoded gray (seems to be damaged, missing the last few scan lines)
|
||||||
new TestData(getClassLoaderResource("/pcx/lena.pcx"), new Dimension(512, 512)), // RLE encoded RGB
|
new TestData(getClassLoaderResource("/pcx/lena.pcx"), new Dimension(512, 512)), // RLE encoded RGB
|
||||||
new TestData(getClassLoaderResource("/pcx/lena2.pcx"), new Dimension(512, 512)), // RLE encoded, 256 color indexed (8 bps/1 channel)
|
new TestData(getClassLoaderResource("/pcx/lena2.pcx"), new Dimension(512, 512)), // RLE encoded, 256 color indexed (8 bps/1 channel)
|
||||||
new TestData(getClassLoaderResource("/pcx/lena3.pcx"), new Dimension(512, 512)), // RLE encoded, 16 color indexed (4 bps/1 channel)
|
new TestData(getClassLoaderResource("/pcx/lena3.pcx"), new Dimension(512, 512)), // RLE encoded, 16 color indexed (4 bps/1 channel)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user