Now with source region/subsampling support also for multipalette.

This commit is contained in:
Harald Kuhr 2012-03-30 16:53:04 +02:00
parent 4463a00667
commit de34ac7ede
2 changed files with 21 additions and 7 deletions

View File

@ -63,6 +63,7 @@ abstract class AbstractMultiPaletteChunk extends IFFChunk implements MultiPalett
protected MutableIndexColorModel.PaletteChange[] initialChanges;
protected MutableIndexColorModel.PaletteChange[][] changes;
protected int lastRow;
protected WeakReference<IndexColorModel> originalPalette;
protected MutableIndexColorModel mutablePalette;
@ -105,7 +106,7 @@ abstract class AbstractMultiPaletteChunk extends IFFChunk implements MultiPalett
public ColorModel getColorModel(final IndexColorModel colorModel, final int rowIndex, final boolean laced) {
if (mutablePalette == null || originalPalette != null && originalPalette.get() != colorModel) {
if (rowIndex < lastRow || mutablePalette == null || originalPalette != null && originalPalette.get() != colorModel) {
originalPalette = new WeakReference<IndexColorModel>(colorModel);
mutablePalette = new MutableIndexColorModel(colorModel);
@ -114,9 +115,23 @@ abstract class AbstractMultiPaletteChunk extends IFFChunk implements MultiPalett
}
}
int row = laced && skipLaced() ? rowIndex / 2 : rowIndex;
if (row < changes.length && changes[row] != null) {
mutablePalette.adjustColorMap(changes[row]);
for (int i = lastRow + 1; i <= rowIndex; i++) {
int row;
if (laced && skipLaced()) {
if (i % 2 != 0) {
continue;
}
row = i / 2;
}
else {
row = i;
}
if (row < changes.length && changes[row] != null) {
mutablePalette.adjustColorMap(changes[row]);
}
}
return mutablePalette;

View File

@ -705,11 +705,10 @@ public class IFFImageReader extends ImageReaderBase {
}
}
private void multiPaletteToRGB(final int srcY, final byte[] indexed, final IndexColorModel colorModel, final byte[] dest, final int destOffset) {
private void multiPaletteToRGB(final int row, final byte[] indexed, final IndexColorModel colorModel, final byte[] dest, final int destOffset) {
final int width = header.width;
// TODO: Assure we have applied color change for all rows up until rowIndex, in case of source region/subsampling
ColorModel palette = paletteChange.getColorModel(colorModel, srcY, isLaced());
ColorModel palette = paletteChange.getColorModel(colorModel, row, isLaced());
for (int x = 0; x < width; x++) {
int pixel = indexed[x] & 0xff;