use of sun.awt.image.IntegerComponentRaster in project jdk8u_jdk by JetBrains.
the class WTrayIconPeer method createNativeImage.
void createNativeImage(BufferedImage bimage) {
Raster raster = bimage.getRaster();
byte[] andMask = new byte[TRAY_ICON_MASK_SIZE];
int[] pixels = ((DataBufferInt) raster.getDataBuffer()).getData();
int npixels = pixels.length;
int ficW = raster.getWidth();
for (int i = 0; i < npixels; i++) {
int ibyte = i / 8;
int omask = 1 << (7 - (i % 8));
if ((pixels[i] & 0xff000000) == 0) {
// Transparent bit
if (ibyte < andMask.length) {
andMask[ibyte] |= omask;
}
}
}
if (raster instanceof IntegerComponentRaster) {
ficW = ((IntegerComponentRaster) raster).getScanlineStride();
}
setNativeIcon(((DataBufferInt) bimage.getRaster().getDataBuffer()).getData(), andMask, ficW, raster.getWidth(), raster.getHeight());
}
use of sun.awt.image.IntegerComponentRaster in project jdk8u_jdk by JetBrains.
the class ImageRepresentation method setPixels.
public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pix, int off, int scansize) {
int lineOff = off;
int poff;
if (src != null) {
src.checkSecurity(null, false);
}
// REMIND: What if the model doesn't fit in default color model?
synchronized (this) {
if (bimage == null) {
if (cmodel == null) {
cmodel = model;
}
createBufferedImage();
}
int[] storage = new int[w];
int yoff;
int pixel;
if (cmodel instanceof IndexColorModel) {
// REMIND: Right now we don't support writing back into ICM
// images.
convertToRGB();
}
if ((model == cmodel) && (biRaster instanceof IntegerComponentRaster)) {
IntegerComponentRaster iraster = (IntegerComponentRaster) biRaster;
if (off == 0 && scansize == w) {
iraster.setDataElements(x, y, w, h, pix);
} else {
// Need to pack the data
for (yoff = y; yoff < y + h; yoff++, lineOff += scansize) {
System.arraycopy(pix, lineOff, storage, 0, w);
iraster.setDataElements(x, yoff, w, 1, storage);
}
}
} else {
if (model.getTransparency() != model.OPAQUE && cmodel.getTransparency() == cmodel.OPAQUE) {
convertToRGB();
}
if (isDefaultBI) {
IntegerComponentRaster iraster = (IntegerComponentRaster) biRaster;
int[] data = iraster.getDataStorage();
if (cmodel.equals(model)) {
int sstride = iraster.getScanlineStride();
int doff = y * sstride + x;
for (yoff = 0; yoff < h; yoff++, lineOff += scansize) {
System.arraycopy(pix, lineOff, data, doff, w);
doff += sstride;
}
// Note: manual modification of pixels, mark the
// raster as changed
iraster.markDirty();
} else {
for (yoff = y; yoff < y + h; yoff++, lineOff += scansize) {
poff = lineOff;
for (int i = 0; i < w; i++) {
storage[i] = model.getRGB(pix[poff++]);
}
iraster.setDataElements(x, yoff, w, 1, storage);
}
}
availinfo |= ImageObserver.SOMEBITS;
} else {
Object tmp = null;
for (yoff = y; yoff < y + h; yoff++, lineOff += scansize) {
poff = lineOff;
for (int xoff = x; xoff < x + w; xoff++) {
pixel = model.getRGB(pix[poff++]);
tmp = cmodel.getDataElements(pixel, tmp);
biRaster.setDataElements(xoff, yoff, tmp);
}
}
availinfo |= ImageObserver.SOMEBITS;
}
}
}
// the region
if (((availinfo & ImageObserver.FRAMEBITS) == 0)) {
newInfo(image, ImageObserver.SOMEBITS, x, y, w, h);
}
}
use of sun.awt.image.IntegerComponentRaster in project jdk8u_jdk by JetBrains.
the class LCMSImageLayout method createImageLayout.
/* This method creates a layout object for given image.
* Returns null if the image is not supported by current implementation.
*/
public static LCMSImageLayout createImageLayout(BufferedImage image) throws ImageLayoutException {
LCMSImageLayout l = new LCMSImageLayout();
switch(image.getType()) {
case BufferedImage.TYPE_INT_RGB:
l.pixelType = PT_ARGB_8;
l.isIntPacked = true;
break;
case BufferedImage.TYPE_INT_ARGB:
l.pixelType = PT_ARGB_8;
l.isIntPacked = true;
break;
case BufferedImage.TYPE_INT_BGR:
l.pixelType = PT_ABGR_8;
l.isIntPacked = true;
break;
case BufferedImage.TYPE_3BYTE_BGR:
l.pixelType = PT_BGR_8;
break;
case BufferedImage.TYPE_4BYTE_ABGR:
l.pixelType = PT_ABGR_8;
break;
case BufferedImage.TYPE_BYTE_GRAY:
l.pixelType = PT_GRAY_8;
break;
case BufferedImage.TYPE_USHORT_GRAY:
l.pixelType = PT_GRAY_16;
break;
default:
/* ColorConvertOp creates component images as
* default destination, so this kind of images
* has to be supported.
*/
ColorModel cm = image.getColorModel();
if (cm instanceof ComponentColorModel) {
ComponentColorModel ccm = (ComponentColorModel) cm;
// verify whether the component size is fine
int[] cs = ccm.getComponentSize();
for (int s : cs) {
if (s != 8) {
return null;
}
}
return createImageLayout(image.getRaster());
}
return null;
}
l.width = image.getWidth();
l.height = image.getHeight();
switch(image.getType()) {
case BufferedImage.TYPE_INT_RGB:
case BufferedImage.TYPE_INT_ARGB:
case BufferedImage.TYPE_INT_BGR:
do {
IntegerComponentRaster intRaster = (IntegerComponentRaster) image.getRaster();
l.nextRowOffset = safeMult(4, intRaster.getScanlineStride());
l.nextPixelOffset = safeMult(4, intRaster.getPixelStride());
l.offset = safeMult(4, intRaster.getDataOffset(0));
l.dataArray = intRaster.getDataStorage();
l.dataArrayLength = 4 * intRaster.getDataStorage().length;
l.dataType = DT_INT;
if (l.nextRowOffset == l.width * 4 * intRaster.getPixelStride()) {
l.imageAtOnce = true;
}
} while (false);
break;
case BufferedImage.TYPE_3BYTE_BGR:
case BufferedImage.TYPE_4BYTE_ABGR:
do {
ByteComponentRaster byteRaster = (ByteComponentRaster) image.getRaster();
l.nextRowOffset = byteRaster.getScanlineStride();
l.nextPixelOffset = byteRaster.getPixelStride();
int firstBand = image.getSampleModel().getNumBands() - 1;
l.offset = byteRaster.getDataOffset(firstBand);
l.dataArray = byteRaster.getDataStorage();
l.dataArrayLength = byteRaster.getDataStorage().length;
l.dataType = DT_BYTE;
if (l.nextRowOffset == l.width * byteRaster.getPixelStride()) {
l.imageAtOnce = true;
}
} while (false);
break;
case BufferedImage.TYPE_BYTE_GRAY:
do {
ByteComponentRaster byteRaster = (ByteComponentRaster) image.getRaster();
l.nextRowOffset = byteRaster.getScanlineStride();
l.nextPixelOffset = byteRaster.getPixelStride();
l.dataArrayLength = byteRaster.getDataStorage().length;
l.offset = byteRaster.getDataOffset(0);
l.dataArray = byteRaster.getDataStorage();
l.dataType = DT_BYTE;
if (l.nextRowOffset == l.width * byteRaster.getPixelStride()) {
l.imageAtOnce = true;
}
} while (false);
break;
case BufferedImage.TYPE_USHORT_GRAY:
do {
ShortComponentRaster shortRaster = (ShortComponentRaster) image.getRaster();
l.nextRowOffset = safeMult(2, shortRaster.getScanlineStride());
l.nextPixelOffset = safeMult(2, shortRaster.getPixelStride());
l.offset = safeMult(2, shortRaster.getDataOffset(0));
l.dataArray = shortRaster.getDataStorage();
l.dataArrayLength = 2 * shortRaster.getDataStorage().length;
l.dataType = DT_SHORT;
if (l.nextRowOffset == l.width * 2 * shortRaster.getPixelStride()) {
l.imageAtOnce = true;
}
} while (false);
break;
default:
return null;
}
l.verify();
return l;
}
Aggregations