mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-03 03:25:28 -04:00
Now with source region/subsampling support also for multipalette.
This commit is contained in:
parent
4463a00667
commit
de34ac7ede
@ -63,6 +63,7 @@ abstract class AbstractMultiPaletteChunk extends IFFChunk implements MultiPalett
|
|||||||
protected MutableIndexColorModel.PaletteChange[] initialChanges;
|
protected MutableIndexColorModel.PaletteChange[] initialChanges;
|
||||||
protected MutableIndexColorModel.PaletteChange[][] changes;
|
protected MutableIndexColorModel.PaletteChange[][] changes;
|
||||||
|
|
||||||
|
protected int lastRow;
|
||||||
protected WeakReference<IndexColorModel> originalPalette;
|
protected WeakReference<IndexColorModel> originalPalette;
|
||||||
protected MutableIndexColorModel mutablePalette;
|
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) {
|
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);
|
originalPalette = new WeakReference<IndexColorModel>(colorModel);
|
||||||
mutablePalette = new MutableIndexColorModel(colorModel);
|
mutablePalette = new MutableIndexColorModel(colorModel);
|
||||||
|
|
||||||
@ -114,9 +115,23 @@ abstract class AbstractMultiPaletteChunk extends IFFChunk implements MultiPalett
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = laced && skipLaced() ? rowIndex / 2 : rowIndex;
|
for (int i = lastRow + 1; i <= rowIndex; i++) {
|
||||||
if (row < changes.length && changes[row] != null) {
|
int row;
|
||||||
mutablePalette.adjustColorMap(changes[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;
|
return mutablePalette;
|
||||||
|
@ -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;
|
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, row, isLaced());
|
||||||
ColorModel palette = paletteChange.getColorModel(colorModel, srcY, isLaced());
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
int pixel = indexed[x] & 0xff;
|
int pixel = indexed[x] & 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user