List of usage examples for java.awt.image VolatileImage IMAGE_INCOMPATIBLE
int IMAGE_INCOMPATIBLE
To view the source code for java.awt.image VolatileImage IMAGE_INCOMPATIBLE.
Click Source Link
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
private void drawOffscreenImage(Image sourceImage) { // image creation if (offscreenBuffer == null) { offscreenBuffer = createCompatibleVolatileImage(sourceImage.getWidth(null), sourceImage.getHeight(null), Transparency.TRANSLUCENT); }//ww w . j av a 2s .c om do { if (offscreenBuffer.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) { // old vImg doesn't work with new GraphicsConfig; re-create it offscreenBuffer = createCompatibleVolatileImage(sourceImage.getWidth(null), sourceImage.getHeight(null), Transparency.TRANSLUCENT); } Graphics2D g = offscreenBuffer.createGraphics(); // // miscellaneous rendering commands... // g.drawImage(sourceImage, 0, 0, null); g.dispose(); } while (offscreenBuffer.contentsLost()); }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
private void drawFromOffscreenBuffer(Graphics2D g, Image sourceImage, Rectangle sourceArea, Rectangle targetArea) {/* w w w . j a va2 s . co m*/ // copying from the image (here, gScreen is the Graphics // object for the onscreen window) do { int returnCode = offscreenBuffer.validate(getGraphicsConfiguration()); if (returnCode == VolatileImage.IMAGE_RESTORED) { // Contents need to be restored drawOffscreenImage(sourceImage); // restore contents } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) { // old vImg doesn't work with new GraphicsConfig; re-create it offscreenBuffer = null; drawOffscreenImage(sourceImage); } int sx0, sx1, sy0, sy1, tx0, tx1, ty0, ty1; sx0 = sourceArea.x; // sx1 = sourceArea.x + sourceArea.width; sy0 = sourceArea.y; // sy1 = sourceArea.y + sourceArea.height; tx0 = targetArea.x; // tx1 = targetArea.x + targetArea.width; ty0 = targetArea.y; // ty1 = targetArea.y + targetArea.height; g.drawImage(offscreenBuffer.getSnapshot().getSubimage(sx0, sy0, sourceArea.width, sourceArea.height), tx0, ty0, targetArea.width, targetArea.height, null); } while (offscreenBuffer.contentsLost()); }