Java Code Examples for java.awt.Image#flush()
The following examples show how to use
java.awt.Image#flush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwingImageCache.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * */ final void flush( ) { if ( htCache.isEmpty( ) ) { return; } Image img; final int n = htCache.size( ); Enumeration<Image> eV = htCache.elements( ); while ( eV.hasMoreElements( ) ) { img = eV.nextElement( ); img.flush( ); } htCache.clear( ); logger.log( ILogger.INFORMATION, Messages.getString( "SwingImageCache.info.flushed.swing.images",//$NON-NLS-1$ new Object[]{ Integer.valueOf( n ) }, idsSWING.getULocale( ) ) ); }
Example 2
Source File: IncorrectClipSurface2SW.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static void draw(Shape clip, Shape to, Image vi, BufferedImage bi, int scale) { Graphics2D big = bi.createGraphics(); big.setComposite(AlphaComposite.Src); big.setClip(clip); Rectangle toBounds = to.getBounds(); int x1 = toBounds.x; int y1 = toBounds.y; int x2 = x1 + toBounds.width; int y2 = y1 + toBounds.height; big.drawImage(vi, x1, y1, x2, y2, 0, 0, toBounds.width / scale, toBounds.height / scale, null); big.dispose(); vi.flush(); }
Example 3
Source File: IncorrectClipSurface2SW.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void draw(Shape clip, Shape to, Image vi, BufferedImage bi, int scale) { Graphics2D big = bi.createGraphics(); big.setComposite(AlphaComposite.Src); big.setClip(clip); Rectangle toBounds = to.getBounds(); int x1 = toBounds.x; int y1 = toBounds.y; int x2 = x1 + toBounds.width; int y2 = y1 + toBounds.height; big.drawImage(vi, x1, y1, x2, y2, 0, 0, toBounds.width / scale, toBounds.height / scale, null); big.dispose(); vi.flush(); }
Example 4
Source File: GroupingMode.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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; }
Example 5
Source File: MainFrame.java From ios-image-util with MIT License | 5 votes |
/** * Generate icon image. * * @param srcImage source image * @param width image width * @param height image height * @param forceIntRGB set true when generate apple watch icon * @throws Exception exception */ public BufferedImage generateIconImage(BufferedImage srcImage, int width, int height, boolean forceIntRGB) throws Exception { BufferedImage buf = this.createBufferedImage(srcImage, width, height, forceIntRGB); int hints = getScalingAlgorithm(); Image img = srcImage.getScaledInstance(width, height, hints); if (forceIntRGB) { Graphics g = buf.getGraphics(); g.setColor(ImageFile.getDefaultBackgroundColor(srcImage)); g.fillRect(0, 0, width, height); } buf.getGraphics().drawImage(img, 0, 0, MainFrame.this); img.flush(); img = null; return forceIntRGB ? buf : fixImageColor(buf, srcImage); }
Example 6
Source File: AVGDialog.java From RipplePower with Apache License 2.0 | 5 votes |
public static void clear() { for (Image img : lazyImages.values()) { img.flush(); img = null; } lazyImages.clear(); }
Example 7
Source File: ComboTest.java From netbeans with Apache License 2.0 | 5 votes |
private static final BufferedImage 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; }
Example 8
Source File: ActionBind.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception { //Audit audit = logger.audit(effectivePerson); ActionResult<Wo> result = new ActionResult<>(); Wo wo = new Wo(); String meta = StringTools.uniqueToken(); /** 二维码内容 */ String url = UriBuilder.fromUri(Config.collect().getAppUrl()).queryParam("meta", meta).build().toASCIIString(); int width = 200; // 二维码图片宽度 int height = 200; // 二维码图片高度 String format = "png";// 二维码的图片格式 Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>(); // hints.put(EncodeHintType.CHARACTER_SET, DefaultCharset.name); // // 内容所使用字符集编码 hints.put(EncodeHintType.MARGIN, "1"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q.toString()); // hints.put(EncodeHintType.QR_VERSION, "7"); BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, width, height, hints); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { image.setRGB(x, y, bitMatrix.get(x, y) ? BLACK : WHITE); } } Graphics2D graphics = image.createGraphics(); Image logo = ImageIO.read(new ByteArrayInputStream(Config.bindLogo())); graphics.drawImage(logo, 68, 68, null); graphics.dispose(); logo.flush(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { ImageIO.write(image, format, out); wo.setImage(Base64.encodeBase64String(out.toByteArray())); } wo.setMeta(meta); result.setData(wo); return result; }
Example 9
Source File: MapImage.java From triplea with GNU General Public License v3.0 | 5 votes |
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(); }
Example 10
Source File: PropertyMarkingTest.java From netbeans with Apache License 2.0 | 5 votes |
private static final BufferedImage toBufferedImage(Image img) { // load the image new ImageIcon(img); BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null)); Graphics g = rep.createGraphics(); g.drawImage(img, 0, 0, null); g.dispose(); img.flush(); return rep; }
Example 11
Source File: CGLGraphicsConfig.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public void destroyBackBuffer(final Image backBuffer) { if (backBuffer != null) { backBuffer.flush(); } }
Example 12
Source File: ActionCheckinCode.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson, String meetingId) throws Exception { Audit audit = logger.audit(effectivePerson); ActionResult<Wo> result = new ActionResult<>(); Wo wo = new Wo(); String meta = StringTools.uniqueToken(); ApplicationServer applicationServer = Config.currentNode().getApplication(); Boolean sslEnable = applicationServer.getSslEnable(); String host = applicationServer.getProxyHost(); int port = applicationServer.getProxyPort(); String applicationUrl = getApplicationUrl(sslEnable, host, port) + "/x_meeting_assemble_control/jaxrs/meeting/" + meetingId + "/checkin"; /** 二维码内容 */ String url = UriBuilder.fromUri(applicationUrl).build().toASCIIString(); int width = 200; // 二维码图片宽度 int height = 200; // 二维码图片高度 String format = "png";// 二维码的图片格式 Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>(); // 内容所使用字符集编码 hints.put(EncodeHintType.MARGIN, "1"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q.toString()); BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, width, height, hints); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { image.setRGB(x, y, bitMatrix.get(x, y) ? BLACK : WHITE); } } Graphics2D graphics = image.createGraphics(); Image logo = ImageIO.read(new ByteArrayInputStream(Config.bindLogo())); graphics.drawImage(logo, 68, 68, null); graphics.dispose(); logo.flush(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { ImageIO.write(image, format, out); wo.setImage(Base64.encodeBase64String(out.toByteArray())); } wo.setMeta(meta); result.setData(wo); audit.log(effectivePerson.getDistinguishedName(), "认证码发送."); return result; }
Example 13
Source File: ActionCheckinCode.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson, String meetingId) throws Exception { Audit audit = logger.audit(effectivePerson); ActionResult<Wo> result = new ActionResult<>(); Wo wo = new Wo(); String meta = StringTools.uniqueToken(); ApplicationServer applicationServer = Config.currentNode().getApplication(); Boolean sslEnable = applicationServer.getSslEnable(); String host = applicationServer.getProxyHost(); int port = applicationServer.getProxyPort(); String applicationUrl = getApplicationUrl(sslEnable, host, port) + "/x_meeting_assemble_control/jaxrs/meeting/" + meetingId + "/checkin"; /** 二维码内容 */ String url = UriBuilder.fromUri(applicationUrl).build().toASCIIString(); int width = 200; // 二维码图片宽度 int height = 200; // 二维码图片高度 String format = "png";// 二维码的图片格式 Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>(); // 内容所使用字符集编码 hints.put(EncodeHintType.MARGIN, "1"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q.toString()); BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, width, height, hints); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { image.setRGB(x, y, bitMatrix.get(x, y) ? BLACK : WHITE); } } Graphics2D graphics = image.createGraphics(); Image logo = ImageIO.read(new ByteArrayInputStream(Config.bindLogo())); graphics.drawImage(logo, 68, 68, null); graphics.dispose(); logo.flush(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { ImageIO.write(image, format, out); wo.setImage(Base64.encodeBase64String(out.toByteArray())); } wo.setMeta(meta); result.setData(wo); audit.log(effectivePerson.getDistinguishedName(), "认证码发送."); return result; }
Example 14
Source File: CGLGraphicsConfig.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public void destroyBackBuffer(final Image backBuffer) { if (backBuffer != null) { backBuffer.flush(); } }
Example 15
Source File: ImageCache.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Sets the cached image for the specified constraints. * * @param image The image to store in cache * @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key * @param w The image width, used as part of cache key * @param h The image height, used as part of cache key * @param args Other arguments to use as part of the cache key * @return true if the image could be cached or false if the image is too big */ public boolean setImage(Image image, GraphicsConfiguration config, int w, int h, Object... args) { if (!isImageCachable(w, h)) return false; int hash = hash(config, w, h, args); lock.writeLock().lock(); try { PixelCountSoftReference ref = map.get(hash); // check if currently in map if (ref != null && ref.get() == image) { return true; } // clear out old if (ref != null) { currentPixelCount -= ref.pixelCount; map.remove(hash); } // add new image to pixel count int newPixelCount = image.getWidth(null) * image.getHeight(null); currentPixelCount += newPixelCount; // clean out lost references if not enough space if (currentPixelCount > maxPixelCount) { while ((ref = (PixelCountSoftReference)referenceQueue.poll()) != null){ //reference lost map.remove(ref.hash); currentPixelCount -= ref.pixelCount; } } // remove old items till there is enough free space if (currentPixelCount > maxPixelCount) { Iterator<Map.Entry<Integer, PixelCountSoftReference>> mapIter = map.entrySet().iterator(); while ((currentPixelCount > maxPixelCount) && mapIter.hasNext()) { Map.Entry<Integer, PixelCountSoftReference> entry = mapIter.next(); mapIter.remove(); Image img = entry.getValue().get(); if (img != null) img.flush(); currentPixelCount -= entry.getValue().pixelCount; } } // finaly put new in map map.put(hash, new PixelCountSoftReference(image, referenceQueue, newPixelCount,hash, config, w, h, args)); return true; } finally { lock.writeLock().unlock(); } }
Example 16
Source File: CGLGraphicsConfig.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public void destroyBackBuffer(final Image backBuffer) { if (backBuffer != null) { backBuffer.flush(); } }
Example 17
Source File: ImageCache.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Sets the cached image for the specified constraints. * * @param image The image to store in cache * @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key * @param w The image width, used as part of cache key * @param h The image height, used as part of cache key * @param args Other arguments to use as part of the cache key * @return true if the image could be cached or false if the image is too big */ public boolean setImage(Image image, GraphicsConfiguration config, int w, int h, Object... args) { if (!isImageCachable(w, h)) return false; int hash = hash(config, w, h, args); lock.writeLock().lock(); try { PixelCountSoftReference ref = map.get(hash); // check if currently in map if (ref != null && ref.get() == image) { return true; } // clear out old if (ref != null) { currentPixelCount -= ref.pixelCount; map.remove(hash); } // add new image to pixel count int newPixelCount = image.getWidth(null) * image.getHeight(null); currentPixelCount += newPixelCount; // clean out lost references if not enough space if (currentPixelCount > maxPixelCount) { while ((ref = (PixelCountSoftReference)referenceQueue.poll()) != null){ //reference lost map.remove(ref.hash); currentPixelCount -= ref.pixelCount; } } // remove old items till there is enough free space if (currentPixelCount > maxPixelCount) { Iterator<Map.Entry<Integer, PixelCountSoftReference>> mapIter = map.entrySet().iterator(); while ((currentPixelCount > maxPixelCount) && mapIter.hasNext()) { Map.Entry<Integer, PixelCountSoftReference> entry = mapIter.next(); mapIter.remove(); Image img = entry.getValue().get(); if (img != null) img.flush(); currentPixelCount -= entry.getValue().pixelCount; } } // finaly put new in map map.put(hash, new PixelCountSoftReference(image, referenceQueue, newPixelCount,hash, config, w, h, args)); return true; } finally { lock.writeLock().unlock(); } }
Example 18
Source File: CGLGraphicsConfig.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public void destroyBackBuffer(final Image backBuffer) { if (backBuffer != null) { backBuffer.flush(); } }
Example 19
Source File: ImageCache.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Sets the cached image for the specified constraints. * * @param image The image to store in cache * @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key * @param w The image width, used as part of cache key * @param h The image height, used as part of cache key * @param args Other arguments to use as part of the cache key * @return true if the image could be cached or false if the image is too big */ public boolean setImage(Image image, GraphicsConfiguration config, int w, int h, Object... args) { if (!isImageCachable(w, h)) return false; int hash = hash(config, w, h, args); lock.writeLock().lock(); try { PixelCountSoftReference ref = map.get(hash); // check if currently in map if (ref != null && ref.get() == image) { return true; } // clear out old if (ref != null) { currentPixelCount -= ref.pixelCount; map.remove(hash); } // add new image to pixel count int newPixelCount = image.getWidth(null) * image.getHeight(null); currentPixelCount += newPixelCount; // clean out lost references if not enough space if (currentPixelCount > maxPixelCount) { while ((ref = (PixelCountSoftReference)referenceQueue.poll()) != null){ //reference lost map.remove(ref.hash); currentPixelCount -= ref.pixelCount; } } // remove old items till there is enough free space if (currentPixelCount > maxPixelCount) { Iterator<Map.Entry<Integer, PixelCountSoftReference>> mapIter = map.entrySet().iterator(); while ((currentPixelCount > maxPixelCount) && mapIter.hasNext()) { Map.Entry<Integer, PixelCountSoftReference> entry = mapIter.next(); mapIter.remove(); Image img = entry.getValue().get(); if (img != null) img.flush(); currentPixelCount -= entry.getValue().pixelCount; } } // finaly put new in map map.put(hash, new PixelCountSoftReference(image, referenceQueue, newPixelCount,hash, config, w, h, args)); return true; } finally { lock.writeLock().unlock(); } }
Example 20
Source File: CGLGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public void destroyBackBuffer(final Image backBuffer) { if (backBuffer != null) { backBuffer.flush(); } }