Java Image Clear clearImage(BufferedImage img)

Here you can find the source of clearImage(BufferedImage img)

Description

Clears image does NOT make copy My "optimization" for not making new buffered image every time render is called

License

Open Source License

Parameter

Parameter Description
img the image to clear

Return

the cleared image

Declaration

public static BufferedImage clearImage(BufferedImage img) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.AlphaComposite;

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

public class Main {
    /**/*from www  . ja  v a 2 s  .c o m*/
     * Clears image does NOT make copy My "optimization" for not making new buffered image every
     * time render is called
     * @param img the image to clear
     *
     * @return the cleared image
     */
    public static BufferedImage clearImage(BufferedImage img) {
        if (img == null) {
            return null;
        }
        Graphics2D g = img.createGraphics();
        g.setComposite(AlphaComposite.Clear);
        g.fillRect(0, 0, img.getWidth(), img.getHeight());
        g.setComposite(AlphaComposite.SrcOver);
        g.dispose();
        return img;
    }
}

Related

  1. clear(BufferedImage image, int col)
  2. clear(Image img)
  3. clearImage(BufferedImage bi)
  4. clearImage(BufferedImage image)
  5. clearImage(BufferedImage img)
  6. clearImage(final BufferedImage image)
  7. clearMergedImagesCache()