java.awt.Image#flush()源码实例Demo

下面列出了java.awt.Image#flush() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: birt   文件: SwingImageCache.java
/**
 * 
 */
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( ) ) );
}
 
源代码2 项目: jdk8u-dev-jdk   文件: IncorrectClipSurface2SW.java
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();
}
 
源代码3 项目: jdk8u_jdk   文件: IncorrectClipSurface2SW.java
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();
}
 
源代码4 项目: TrakEM2   文件: GroupingMode.java
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;
}
 
源代码5 项目: RipplePower   文件: AVGDialog.java
public static void clear() {
	for (Image img : lazyImages.values()) {
		img.flush();
		img = null;
	}
	lazyImages.clear();
}
 
源代码6 项目: netbeans   文件: ComboTest.java
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;
}
 
源代码7 项目: netbeans   文件: PropertyMarkingTest.java
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;
}
 
源代码8 项目: triplea   文件: MapImage.java
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();
}
 
源代码9 项目: o2oa   文件: ActionBind.java
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;
}
 
源代码10 项目: ios-image-util   文件: MainFrame.java
/**
 * 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);
}
 
源代码11 项目: dragonwell8_jdk   文件: CGLGraphicsConfig.java
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}
 
源代码12 项目: openjdk-8-source   文件: ImageCache.java
/**
 * 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();
    }
}
 
源代码13 项目: openjdk-jdk9   文件: CGLGraphicsConfig.java
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}
 
源代码14 项目: jdk8u60   文件: ImageCache.java
/**
 * 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();
    }
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: CGLGraphicsConfig.java
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}
 
源代码16 项目: JDKSourceCode1.8   文件: ImageCache.java
/**
 * 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();
    }
}
 
源代码17 项目: jdk8u-jdk   文件: CGLGraphicsConfig.java
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}
 
源代码18 项目: o2oa   文件: ActionCheckinCode.java
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;
}
 
源代码19 项目: o2oa   文件: ActionCheckinCode.java
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;
}
 
源代码20 项目: openjdk-8-source   文件: CGLGraphicsConfig.java
@Override
public void destroyBackBuffer(final Image backBuffer) {
    if (backBuffer != null) {
        backBuffer.flush();
    }
}