Java Image Clear clearImage(BufferedImage bi)

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

Description

Sets all pixels of the given image to black and fully transparent (RGBA 0).

License

Open Source License

Parameter

Parameter Description
bi The image to clear.

Declaration

public static void clearImage(BufferedImage bi) 

Method Source Code


//package com.java2s;
/* //w  w w  .  ja  v  a2 s . c om
 * This file is part of BMix.
 *
 *    BMix is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 * 
 *    BMix is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with BMix.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

import java.awt.image.BufferedImage;

public class Main {
    /**
     * Sets all pixels of the given image to black and fully transparent
     * (RGBA 0).
     * 
     * @param bi The image to clear.
     */
    public static void clearImage(BufferedImage bi) {
        for (int x = 0; x < bi.getWidth(); x++) {
            for (int y = 0; y < bi.getHeight(); y++) {
                bi.setRGB(x, y, 0);
            }
        }
    }
}

Related

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