#285: Fix for non-spec BMPs without palette.

This commit is contained in:
Harald Kuhr 2016-10-17 20:36:40 +02:00
parent b116b4b5a7
commit 17eeda210e
3 changed files with 9 additions and 6 deletions

View File

@ -160,6 +160,7 @@ public final class BMPImageReader extends ImageReaderBase {
}
}
if (colors.length > 0) {
// There might be more entries in the color map, but we ignore these for reading
int mapSize = Math.min(colors.length, 1 << header.getBitCount());
@ -169,6 +170,7 @@ public final class BMPImageReader extends ImageReaderBase {
colorMap = new IndexColorModel(bits, mapSize, colors, 0, false, -1, DataBuffer.TYPE_BYTE);
}
}
}
return colorMap;
}

View File

@ -108,7 +108,8 @@ public class BMPImageReaderTest extends ImageReaderAbstractTest<BMPImageReader>
new TestData(getClassLoaderResource("/bmp/blauesglas_24.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32_bitmask888.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32_bitmask888_reversed.bmp"), new Dimension(301, 331))
new TestData(getClassLoaderResource("/bmp/blauesglas_32_bitmask888_reversed.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/24bitpalette.bmp"), new Dimension(320, 200))
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB