334 } |
334 } |
335 |
335 |
336 public native void setICMpixels(int x, int y, int w, int h, int[] lut, |
336 public native void setICMpixels(int x, int y, int w, int h, int[] lut, |
337 byte[] pix, int off, int scansize, |
337 byte[] pix, int off, int scansize, |
338 IntegerComponentRaster ict); |
338 IntegerComponentRaster ict); |
339 |
|
340 public native void setBytePixels(int x, int y, int w, int h, byte[] pix, |
|
341 int off, int scansize, |
|
342 ByteComponentRaster bct, int chanOff); |
|
343 public native int setDiffICM(int x, int y, int w, int h, int[] lut, |
339 public native int setDiffICM(int x, int y, int w, int h, int[] lut, |
344 int transPix, int numLut, IndexColorModel icm, |
340 int transPix, int numLut, IndexColorModel icm, |
345 byte[] pix, int off, int scansize, |
341 byte[] pix, int off, int scansize, |
346 ByteComponentRaster bct, int chanOff); |
342 ByteComponentRaster bct, int chanOff); |
347 static boolean s_useNative = true; |
343 static boolean s_useNative = true; |
448 } |
444 } |
449 else if ((cmodel == model) && |
445 else if ((cmodel == model) && |
450 (biRaster instanceof ByteComponentRaster) && |
446 (biRaster instanceof ByteComponentRaster) && |
451 (biRaster.getNumDataElements() == 1)){ |
447 (biRaster.getNumDataElements() == 1)){ |
452 ByteComponentRaster bt = (ByteComponentRaster) biRaster; |
448 ByteComponentRaster bt = (ByteComponentRaster) biRaster; |
453 if (w*h > 200) { |
449 if (off == 0 && scansize == w) { |
454 if (off == 0 && scansize == w) { |
450 bt.putByteData(x, y, w, h, pix); |
455 bt.putByteData(x, y, w, h, pix); |
|
456 } |
|
457 else { |
|
458 byte[] bpix = new byte[w]; |
|
459 poff = off; |
|
460 for (int yoff=y; yoff < y+h; yoff++) { |
|
461 System.arraycopy(pix, poff, bpix, 0, w); |
|
462 bt.putByteData(x, yoff, w, 1, bpix); |
|
463 poff += scansize; |
|
464 } |
|
465 } |
|
466 } |
451 } |
467 else { |
452 else { |
468 // Only is faster if #pixels |
453 byte[] bpix = new byte[w]; |
469 // Note that setBytePixels modifies the raster directly |
454 poff = off; |
470 // so we must mark it as changed afterwards |
455 for (int yoff=y; yoff < y+h; yoff++) { |
471 setBytePixels(x, y, w, h, pix, off, scansize, bt, |
456 System.arraycopy(pix, poff, bpix, 0, w); |
472 bt.getDataOffset(0)); |
457 bt.putByteData(x, yoff, w, 1, bpix); |
473 bt.markDirty(); |
458 poff += scansize; |
|
459 } |
474 } |
460 } |
475 } |
461 } |
476 else { |
462 else { |
477 for (int yoff=y; yoff < y+h; yoff++, lineOff += scansize) { |
463 for (int yoff=y; yoff < y+h; yoff++, lineOff += scansize) { |
478 poff = lineOff; |
464 poff = lineOff; |