verify Pixel With Threshold - Android Graphics

Android examples for Graphics:Pixel

Description

verify Pixel With Threshold

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    /**//  w ww .  j a v a2  s .  c om
     * @return True if close enough
     */
    public static boolean verifyPixelWithThreshold(int color,
            int expectedColor, int threshold) {
        int diff = Math.abs(Color.red(color) - Color.red(expectedColor))
                + Math.abs(Color.green(color) - Color.green(expectedColor))
                + Math.abs(Color.blue(color) - Color.blue(expectedColor));
        return diff <= threshold;
    }
}

Related Tutorials