Here you can find the source of nonTransparentPixels(BufferedImage image)
Parameter | Description |
---|---|
image | The image to count the number of non transparent pixels in |
public static int nonTransparentPixels(BufferedImage image)
//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; } }