get Average Of Pixel Array - Android Graphics

Android examples for Graphics:Bitmap Byte Array

Description

get Average Of Pixel Array

Demo Code


//package com.book2s;

import android.graphics.Color;

public class Main {
    public static int getAverageOfPixelArray(int[] pixels) {
        long sumRed = 0;
        for (int i = 0; i < pixels.length; i++) {
            sumRed += Color.red(pixels[i]);
        }/*w  w w  .  j  a v a  2  s  . c  om*/
        int averageRed = (int) (sumRed / pixels.length);
        return averageRed;
    }
}

Related Tutorials