if (isSameCM && (cmodel != model) && (srcLUT != null) &&
(model instanceof IndexColorModel) &&
(biRaster instanceof ByteComponentRaster))
{
IndexColorModel icm = (IndexColorModel) model;
ByteComponentRaster bct = (ByteComponentRaster) biRaster;
int numlut = numSrcLUT;
if (setDiffICM(x, y, w, h, srcLUT, srcLUTtransIndex,
numSrcLUT, icm,
pix, off, scansize, bct,
bct.getDataOffset(0)) == 0) {
convertToRGB();
}
else {
// Note that setDiffICM modified the raster directly
// so we must mark it as changed
bct.markDirty();
if (numlut != numSrcLUT) {
boolean hasAlpha = icm.hasAlpha();
if (srcLUTtransIndex != -1) {
hasAlpha = true;
}
int nbits = icm.getPixelSize();
icm = new IndexColorModel(nbits,
numSrcLUT, srcLUT,
0, hasAlpha,
srcLUTtransIndex,
(nbits > 8
? DataBuffer.TYPE_USHORT
: DataBuffer.TYPE_BYTE));
cmodel = icm;
bimage = createImage(icm, bct, false, null);
}
return;
}
}
if (isDefaultBI) {
int pixel;
IntegerComponentRaster iraster =
(IntegerComponentRaster) biRaster;
if (srcLUT != null && model instanceof IndexColorModel) {
if (model != srcModel) {
// Fill in the new lut
((IndexColorModel)model).getRGBs(srcLUT);
srcModel = model;
}
if (s_useNative) {
// Note that setICMpixels modifies the raster directly
// so we must mark it as changed afterwards
setICMpixels(x, y, w, h, srcLUT, pix, off, scansize,
iraster);
iraster.markDirty();
}
else {
int[] storage = new int[w*h];
int soff = 0;
// It is an IndexColorModel
for (int yoff=0; yoff < h; yoff++,
lineOff += scansize) {
poff = lineOff;
for (int i=0; i < w; i++) {
storage[soff++] = srcLUT[pix[poff++]&0xff];
}
}
iraster.setDataElements(x, y, w, h, storage);
}
}
else {
int[] storage = new int[w];
for (int yoff=y; yoff < y+h; yoff++, lineOff += scansize) {
poff = lineOff;
for (int i=0; i < w; i++) {
storage[i] = model.getRGB(pix[poff++]&0xff);
}
iraster.setDataElements(x, yoff, w, 1, storage);
}
availinfo |= ImageObserver.SOMEBITS;
}
}
else if ((cmodel == model) &&
(biRaster instanceof ByteComponentRaster) &&
(biRaster.getNumDataElements() == 1)){
ByteComponentRaster bt = (ByteComponentRaster) biRaster;
if (w*h > 200) {
if (off == 0 && scansize == w) {
bt.putByteData(x, y, w, h, pix);
}
else {
byte[] bpix = new byte[w];
poff = off;
for (int yoff=y; yoff < y+h; yoff++) {
System.arraycopy(pix, poff, bpix, 0, w);
bt.putByteData(x, yoff, w, 1, bpix);
poff += scansize;
}
}
}
else {
// Only is faster if #pixels
// Note that setBytePixels modifies the raster directly
// so we must mark it as changed afterwards
setBytePixels(x, y, w, h, pix, off, scansize, bt,
bt.getDataOffset(0));
bt.markDirty();
}
}
else {
for (int yoff=y; yoff < y+h; yoff++, lineOff += scansize) {
poff = lineOff;