Java BufferedImage Transparent nonTransparentPixels(BufferedImage image)

Here you can find the source of nonTransparentPixels(BufferedImage image)

Description

Counts the numbers of non transparent pixels in a given BufferedImage .

License

Open Source License

Parameter

Parameter Description
image The image to count the number of non transparent pixels in

Return

The number of non transparent pixels

Declaration

public static int nonTransparentPixels(BufferedImage image) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.  j av a 2 s.  c  om*/
 * ATLauncher - https://github.com/ATLauncher/ATLauncher
 * Copyright (C) 2013 ATLauncher
 *
 * This program 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.
 *
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.image.BufferedImage;

public class Main {
    /**
     * Counts the numbers of non transparent pixels in a given {@link BufferedImage}.
     *
     * @param image The image to count the number of non transparent pixels in
     * @return The number of non transparent pixels
     */
    public static int nonTransparentPixels(BufferedImage image) {
        int count = 0;
        for (int x = 0; x < 8; x++) {
            for (int y = 0; y < 8; y++) {
                if (image.getRGB(x, y) == -1) {
                    count++;
                }
            }
        }
        return count;
    }
}

Related

  1. ConvToTransparentImage(BufferedImage src, float alpha)
  2. cutTransparentBorder(BufferedImage src)
  3. fixTransparency(String var0, BufferedImage var1)
  4. makeTransparency(BufferedImage image, int color)
  5. makeTranspBufferedImage(Image image)
  6. pickBestTransparency(BufferedImage image)
  7. setTranformImagePixels(BufferedImage origImg, Color paramColor, int colorRangePerc, Vector transPixel, Shape cutoutShape)
  8. transparentBG(BufferedImage image, Boolean transparent)
  9. transparentColor(BufferedImage src, Color trColor)