stretchedGraphics = (Graphics2D) stretchedImage.getGraphics();
tracker.removeImage(i, 1); bgImage.getGraphics().drawImage(i, 0,0, null); tracker.addImage(bgImage, 0); try {
/** * Clears a volatile image */ public static void clearVolatileImage(@Nonnull VolatileImage volatileImage) { Graphics2D graphics = (Graphics2D) volatileImage.getGraphics(); try { graphics.setComposite(AlphaComposite.DstOut); graphics.fillRect(0, 0, volatileImage.getWidth(), volatileImage.getHeight()); } finally { graphics.dispose(); } }
void mergeBuffers() { VolatileImage vi = createBackBuffer(); Graphics2D g2d = (Graphics2D) vi.getGraphics(); MapLayer[] layers = getContext().getLayers(); for (int i = 0, max = layers.length; i < max; i++) { // for (int i= layers.length-1; i>=0; i--){ MapLayer layer = layers[i]; BufferedImage img = stock.get(layer); if (img != null) { g2d.drawImage(img, null, 0, 0); } } comp.setBuffer(vi); }
/** * Creates the off-screen buffer used to perform double buffered rendering of the animated * panel. */ protected void createBackBuffer (GraphicsConfiguration gc) { // if we have an old image, clear it out if (_backimg != null) { _backimg.flush(); _bgfx.dispose(); } // create the offscreen buffer int width = _window.getWidth(), height = _window.getHeight(); _backimg = gc.createCompatibleVolatileImage(width, height); // fill the back buffer with white _bgfx = (Graphics2D)_backimg.getGraphics(); _bgfx.fillRect(0, 0, width, height); // clear out our frame graphics in case that became invalid for // the same reasons our back buffer became invalid if (_fgfx != null) { _fgfx.dispose(); _fgfx = null; } // Log.info("Created back buffer [" + width + "x" + height + "]."); }
/** * Creates the off-screen buffer used to perform double buffered rendering of the animated * panel. */ protected void createBackBuffer (GraphicsConfiguration gc) { // if we have an old image, clear it out if (_backimg != null) { _backimg.flush(); _bgfx.dispose(); } // create the offscreen buffer int width = _window.getWidth(), height = _window.getHeight(); _backimg = gc.createCompatibleVolatileImage(width, height); // fill the back buffer with white _bgfx = (Graphics2D)_backimg.getGraphics(); _bgfx.fillRect(0, 0, width, height); // clear out our frame graphics in case that became invalid for // the same reasons our back buffer became invalid if (_fgfx != null) { _fgfx.dispose(); _fgfx = null; } // Log.info("Created back buffer [" + width + "x" + height + "]."); }
private VolatileImage vImg; @Override public void paint(Graphics g) { if (gc==null) gc = this.getGraphicsConfiguration(); do { boolean sizeChanged = false; sizeChanged = (vImg!=null&&(vImg.getWidth()!=getWidth()|| vImg.getHeight()!=getHeight())); if (vImg == null || vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE || sizeChanged) { vImg = gc.createCompatibleVolatileImage(getWidth(), getHeight()); vImg.setAccelerationPriority(1); } final Graphics gimg = vImg.getGraphics(); if (gimg instanceof Graphics2D) { renderContents((Graphics2D) gimg); gimg.dispose(); g.drawImage(vImg, 0, 0, null); } else { throw new UnsupportedOperationException("Rendering impossible, graphics are not of Graphics2D class"); } } while (vImg.contentsLost()); updateAnimationNo(); }
Graphics og = image.getGraphics();
tracker.removeImage(i, 1); bgImage.getGraphics().drawImage(i, 0,0, null); tracker.addImage(bgImage, 0); try {
tracker.removeImage(i, 1); bgImage.getGraphics().drawImage(i, 0,0, null); tracker.addImage(bgImage, 0); try {
tracker.removeImage(i, 1); bgImage.getGraphics().drawImage(i, 0,0, null); tracker.addImage(bgImage, 0); try {
final Graphics g = img.getGraphics();