use of java.awt.image.ColorModel 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.ColorModel in project jdk8u_jdk by JetBrains.
the class GLXGraphicsConfig method createAcceleratedImage.
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
@Override
public Image createAcceleratedImage(Component target, int width, int height) {
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr = model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr, model.isAlphaPremultiplied());
}
use of java.awt.image.ColorModel in project jdk8u_jdk by JetBrains.
the class X11GraphicsConfig method createAcceleratedImage.
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
public Image createAcceleratedImage(Component target, int width, int height) {
// As of 1.7 we no longer create pmoffscreens here...
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr = model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr, model.isAlphaPremultiplied());
}
use of java.awt.image.ColorModel in project jdk8u_jdk by JetBrains.
the class WGLVolatileSurfaceManager method initAcceleratedSurface.
/**
* Create a pbuffer-based SurfaceData object (or init the backbuffer
* of an existing window if this is a double buffered GraphicsConfig).
*/
protected SurfaceData initAcceleratedSurface() {
SurfaceData sData;
Component comp = vImg.getComponent();
WComponentPeer peer = (comp != null) ? (WComponentPeer) comp.getPeer() : null;
try {
boolean createVSynced = false;
boolean forceback = false;
if (context instanceof Boolean) {
forceback = ((Boolean) context).booleanValue();
if (forceback) {
BufferCapabilities caps = peer.getBackBufferCaps();
if (caps instanceof ExtendedBufferCapabilities) {
ExtendedBufferCapabilities ebc = (ExtendedBufferCapabilities) caps;
if (ebc.getVSync() == VSYNC_ON && ebc.getFlipContents() == COPIED) {
createVSynced = true;
forceback = false;
}
}
}
}
if (forceback) {
// peer must be non-null in this case
sData = WGLSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
} else {
WGLGraphicsConfig gc = (WGLGraphicsConfig) vImg.getGraphicsConfig();
ColorModel cm = gc.getColorModel(vImg.getTransparency());
int type = vImg.getForcedAccelSurfaceType();
// use the forced type, otherwise choose one based on caps
if (type == OGLSurfaceData.UNDEFINED) {
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ? OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
}
if (createVSynced) {
sData = WGLSurfaceData.createData(peer, vImg, type);
} else {
sData = WGLSurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, type);
}
}
} catch (NullPointerException ex) {
sData = null;
} catch (OutOfMemoryError er) {
sData = null;
}
return sData;
}
use of java.awt.image.ColorModel in project jdk8u_jdk by JetBrains.
the class ColCvtAlpha method main.
public static void main(String[] args) {
BufferedImage src = new BufferedImage(1, 10, BufferedImage.TYPE_INT_ARGB);
// Set src pixel values
Color pelColor = new Color(100, 100, 100, 128);
for (int i = 0; i < 10; i++) {
src.setRGB(0, i, pelColor.getRGB());
}
ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] { 8, 8 }, true, src.getColorModel().isAlphaPremultiplied(), Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, 100, 100, 2, 200, new int[] { 0, 1 });
WritableRaster wr = Raster.createWritableRaster(sm, new Point(0, 0));
BufferedImage dst = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
dst = dst.getSubimage(0, 0, 1, 10);
ColorConvertOp op = new ColorConvertOp(null);
op.filter(src, dst);
for (int i = 0; i < 10; i++) {
if (((dst.getRGB(0, i) >> 24) & 0xff) != 128) {
throw new RuntimeException("Incorrect destination alpha value.");
}
}
}
Aggregations