/** The method creates a BufferedImage which represents the same Image as the * parameter but consumes less memory. */ static final Image toBufferedImage(Image img) { // load the image new javax.swing.ImageIcon(img, ""); if (img.getHeight(null)*img.getWidth(null) > 24*24) { return img; } java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null)); java.awt.Graphics g = rep.createGraphics(); g.drawImage(img, 0, 0, null); g.dispose(); img.flush(); return rep; }
private static BufferedImage readImage(final ImageIcon imageIcon) { final Image tmpImage = imageIcon.getImage(); final BufferedImage image = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(tmpImage, 0, 0, null); tmpImage.flush(); return image; }
h = Math.max(h/2, height); img = commonResize(prev, w, h, hint); prev.flush();
/** The method creates a BufferedImage which represents the same Image as the * parameter but consumes less memory. */ static final Image toBufferedImage(Image img) { // load the image new javax.swing.ImageIcon(img, ""); if (img.getHeight(null)*img.getWidth(null) > 24*24) { return img; } java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null)); java.awt.Graphics g = rep.createGraphics(); g.drawImage(img, 0, 0, null); g.dispose(); img.flush(); return rep; }
/** * @param _useCache the useCache to set */ public void setUseCache(boolean _useCache) { useCache_ = _useCache; if (!_useCache && cache_ != null) { cache_.flush(); cache_ = null; } }
void resetPixels(Object pixels) { if (pixels==null) { if (img!=null) { img.flush(); img = null; } } }
private void flushImage() { if (limited != null) { limited.flush(); limited = null; } }
@Override protected void finalize() throws Throwable { if (colorBar != null) colorBar.flush(); colorBar = null; super.finalize(); }
/** * Schedules the offscreen resources taken by the offscreen buffer to * be reclaimed. Note that this does not force garbage collection */ public void releaseOffscreenResources() { offscreen.flush(); offgraphics.dispose(); offscreen = null; offgraphics = null; }
public static BufferedImage toBufferedImage(Image _in, int _width, int _height) { BufferedImage out = new BufferedImage(_width, _height, BufferedImage.TYPE_3BYTE_BGR); Graphics g = out.getGraphics(); g.drawImage(_in, 0, 0, _width, _height, null); _in.flush(); return out; }
public static BufferedImage createBufferedImage(Image imageIn, int imageType) { BufferedImage bufferedImageOut = new BufferedImage(imageIn .getWidth(null), imageIn.getHeight(null), imageType); Graphics g = bufferedImageOut.getGraphics(); g.drawImage(imageIn, 0, 0, null); imageIn.flush(); return bufferedImageOut; }
/** The method creates a BufferedImage which represents the same Image as the * parameter but consumes less memory. */ static final Image toBufferedImage(Image img) { // load the image new javax.swing.ImageIcon(img); java.awt.image.BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null)); java.awt.Graphics g = rep.createGraphics(); g.drawImage(img, 0, 0, null); g.dispose(); img.flush(); return rep; }
ImageIcon imageIcon = new ImageIcon(imageAbsolutePath); Image tmpImage = imageIcon.getImage(); BufferedImage image = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(tmpImage, 0, 0, null); tmpImage.flush(); return image;
public void loadMaps(final ResourceLoader loader) { final Image smallFromFile = loadImage(loader, Constants.SMALL_MAP_FILENAME, Constants.SMALL_MAP_EXTENSIONS); smallMapImage = Util.newImage(smallFromFile.getWidth(null), smallFromFile.getHeight(null), false); final Graphics g = smallMapImage.getGraphics(); g.drawImage(smallFromFile, 0, 0, null); g.dispose(); smallFromFile.flush(); }
static public final boolean saveAsPNG(final ImageProcessor ip, final String path) { Image awt = null; try { awt = ip.createImage(); return ImageSaver.saveAsPNG(awt, path); } catch (Exception e) { IJError.print(e); return false; } finally { if (null != awt) awt.flush(); } }
private void resetBackBuffer() { if(backBufferGraphics!=null){ backBufferGraphics.dispose(); backBufferGraphics=null; } if(backBufferImage!=null){ backBufferImage.flush(); backBufferImage=null; } backBufferWidth=getSize().width; backBufferHeight=getSize().height; backBufferImage=createImage(backBufferWidth,backBufferHeight); backBufferGraphics=backBufferImage.getGraphics(); }
public static byte[] scaleImage(BaseScaledImage scaler, Image image, BaseImageFormat encodingFormat) throws IOException { scaler.scaleImage(image); byte[] result = encodeImage(scaler.getScaledImage(), encodingFormat); scaler.flush(); image.flush(); return result; }
protected BufferedImage makeImage( final ImageProcessor ip, final FloatProcessor mask ) { final BufferedImage transformedImage = new BufferedImage( ip.getWidth(), ip.getHeight(), null == mask ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB ); final Image img = ip.createImage(); transformedImage.createGraphics().drawImage( img, 0, 0, null ); img.flush(); if (null != mask) { transformedImage.getAlphaRaster().setPixels( 0, 0, ip.getWidth(), ip.getHeight(), ( float[] )mask.getPixels() ); } return transformedImage; }
/** Flush all mipmaps, and forget all mipmaps and imps. */ public final void removeAndFlushAll() { for (final Pyramid p : pyramids.values()) { p.replace(null); // the imp may need cleanup for (int i=0; i<p.images.length; i++) { if (null == p.images[i]) continue; p.images[i].flush(); CachingThread.storeArrayForReuse(p.images[i]); } } reset(); }
public ImagePlus getFlatImage(final Layer layer, final Rectangle srcRect_, final double scale, final int c_alphas, final int type, final Class<?> clazz, final List<? extends Displayable> al_displ, final boolean quality, final Color background, final Displayable active) { final Image bi = getFlatAWTImage(layer, srcRect_, scale, c_alphas, type, clazz, al_displ, quality, background, active); final ImagePlus imp = new ImagePlus(layer.getPrintableTitle(), bi); final Calibration impCalibration = layer.getParent().getCalibrationCopy(); impCalibration.pixelWidth /= scale; impCalibration.pixelHeight /= scale; imp.setCalibration(impCalibration); bi.flush(); return imp; }