Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static int getPixelsCount(Bitmap bitmap) {
        int hlen = bitmap.getWidth(), vlen = bitmap.getHeight();
        int toReturn = 0;
        for (int i = 0; i < vlen; i++) {
            for (int j = 0; j < hlen; j++) {
                if ((bitmap.getPixel(j, i) & 0xff) > 0) {
                    toReturn++;
                }
            }
        }

        return toReturn;
    }
}