use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.
the class ImageRepresentation method getOpaqueRGBImage.
public BufferedImage getOpaqueRGBImage() {
if (bimage.getType() == BufferedImage.TYPE_INT_ARGB) {
int w = bimage.getWidth();
int h = bimage.getHeight();
int size = w * h;
// Note that we steal the data array here, but only for reading...
DataBufferInt db = (DataBufferInt) biRaster.getDataBuffer();
int[] pixels = SunWritableRaster.stealData(db, 0);
for (int i = 0; i < size; i++) {
if ((pixels[i] >>> 24) != 0xff) {
return bimage;
}
}
ColorModel opModel = new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff);
int[] bandmasks = { 0x00ff0000, 0x0000ff00, 0x000000ff };
WritableRaster opRaster = Raster.createPackedRaster(db, w, h, w, bandmasks, null);
try {
BufferedImage opImage = createImage(opModel, opRaster, false, null);
return opImage;
} catch (Exception e) {
return bimage;
}
}
return bimage;
}
use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.
the class CGLGraphicsConfig method createCompatibleImage.
@Override
public BufferedImage createCompatibleImage(int width, int height) {
ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
WritableRaster raster = model.createCompatibleWritableRaster(width, height);
return new BufferedImage(model, raster, model.isAlphaPremultiplied(), null);
}
use of java.awt.image.DirectColorModel in project chipKIT32-MAX by chipKIT32.
the class PGraphics2D method allocate.
//public void setParent(PApplet parent)
//public void setPrimary(boolean primary)
//public void setPath(String path)
//public void setSize(int iwidth, int iheight)
protected void allocate() {
pixelCount = width * height;
pixels = new int[pixelCount];
if (primarySurface) {
cm = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
;
mis = new MemoryImageSource(width, height, pixels, 0, width);
mis.setFullBufferUpdates(true);
mis.setAnimated(true);
image = Toolkit.getDefaultToolkit().createImage(mis);
}
}
use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.
the class GLXGraphicsConfig method createCompatibleImage.
@Override
public BufferedImage createCompatibleImage(int width, int height) {
ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
WritableRaster raster = model.createCompatibleWritableRaster(width, height);
return new BufferedImage(model, raster, model.isAlphaPremultiplied(), null);
}
use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.
the class WritableRasterNative method createNativeRaster.
public static WritableRasterNative createNativeRaster(ColorModel cm, SurfaceData sd, int width, int height) {
SampleModel smHw = null;
int dataType = 0;
int scanStride = width;
switch(cm.getPixelSize()) {
case 8:
case 12:
// 8-bits uses PixelInterleavedSampleModel
if (cm.getPixelSize() == 8) {
dataType = DataBuffer.TYPE_BYTE;
} else {
dataType = DataBuffer.TYPE_USHORT;
}
int[] bandOffsets = new int[1];
bandOffsets[0] = 0;
smHw = new PixelInterleavedSampleModel(dataType, width, height, 1, scanStride, bandOffsets);
break;
// all others use SinglePixelPackedSampleModel
case 15:
case 16:
dataType = DataBuffer.TYPE_USHORT;
int[] bitMasks = new int[3];
DirectColorModel dcm = (DirectColorModel) cm;
bitMasks[0] = dcm.getRedMask();
bitMasks[1] = dcm.getGreenMask();
bitMasks[2] = dcm.getBlueMask();
smHw = new SinglePixelPackedSampleModel(dataType, width, height, scanStride, bitMasks);
break;
case 24:
case 32:
dataType = DataBuffer.TYPE_INT;
bitMasks = new int[3];
dcm = (DirectColorModel) cm;
bitMasks[0] = dcm.getRedMask();
bitMasks[1] = dcm.getGreenMask();
bitMasks[2] = dcm.getBlueMask();
smHw = new SinglePixelPackedSampleModel(dataType, width, height, scanStride, bitMasks);
break;
default:
throw new InternalError("Unsupported depth " + cm.getPixelSize());
}
DataBuffer dbn = new DataBufferNative(sd, dataType, width, height);
return new WritableRasterNative(smHw, dbn);
}
Aggregations