Here you can find the source of clearImage(BufferedImage img)
Parameter | Description |
---|---|
img | The image to clear |
static void clearImage(BufferedImage img)
//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(); } }