Java Image Clear clearImage(BufferedImage img)

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

Description

Clear a transparent image to 100% transparent

License

Open Source License

Parameter

Parameter Description
img The image to clear

Declaration

static void clearImage(BufferedImage img) 

Method Source Code


//package com.java2s;
/*/*from   w w w .ja va 2  s  .  c  o m*/
 * %W% %E%
 *
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.awt.AlphaComposite;
import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

public class Main {
    /**
     * Clear a transparent image to 100% transparent
     *
     * @param img The image to clear
     */
    static void clearImage(BufferedImage img) {
        Graphics2D g2 = img.createGraphics();
        g2.setComposite(AlphaComposite.Clear);
        g2.fillRect(0, 0, img.getWidth(), img.getHeight());
        g2.dispose();
    }
}

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()