Example usage for android.graphics Bitmap getPixel

List of usage examples for android.graphics Bitmap getPixel

Introduction

In this page you can find the example usage for android.graphics Bitmap getPixel.

Prototype

@ColorInt
public int getPixel(int x, int y) 

Source Link

Document

Returns the Color at the specified location.

Usage

From source file:Main.java

public static int getPixColor(Bitmap src) {
    int pixelColor;
    pixelColor = src.getPixel(5, 5);
    return pixelColor;
}

From source file:Main.java

private static int getRGBAdd(Bitmap img, int x, int y) {
    int value = 0;
    int rgb = img.getPixel(x, y);
    value += (rgb >> 16) & 0xFF;
    value += (rgb >> 8) & 0xFF;
    value += rgb & 0xFF;// www .j  a  va2s  .c om
    return value;
}

From source file:Main.java

public static boolean compareColorArea(Bitmap userFinalBitmap, Bitmap colored, int w, int h) {
    if (Math.abs(userFinalBitmap.getPixel(w, h) - (colored.getPixel(w, h))) <= 100) {
        return true;
    }//w  w  w .  j  av a 2s  . c o  m
    return false;
}

From source file:Main.java

public static int couleurPrincipale(Bitmap image) {
    Bitmap onePixelBitmap = Bitmap.createScaledBitmap(image, 1, 1, true);
    return onePixelBitmap.getPixel(0, 0);
}

From source file:Main.java

public static int getDominantColor(Bitmap bitmap) {
    Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
    final int color = newBitmap.getPixel(0, 0);
    newBitmap.recycle();/*from  w  w  w .ja v a2 s.com*/
    return color;
}

From source file:Main.java

public static int getDominantColor(Bitmap bitmap) {
    try {//from w  w  w. ja  va  2s.  c o m
        Bitmap onePixelBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
        return onePixelBitmap.getPixel(0, 0);
    } catch (Exception ex) {
        return Color.BLACK;
    }
}

From source file:Main.java

public static boolean isSameByPosition(Bitmap bitmap, Bitmap other, Point[] points) {
    for (Point p : points) {
        if (bitmap.getPixel(p.x, p.y) != bitmap.getPixel(p.x, p.y))
            return false;
    }//w  ww. j a v a 2 s.  c om
    return true;
}

From source file:Main.java

public static int getHighlightColorFromBitmap(final Bitmap bitmap) {
    int incolor = Color.BLACK;
    if (null != bitmap) {
        final Bitmap bitmap1px = Bitmap.createScaledBitmap(bitmap, 1, 1, false);
        incolor = bitmap1px.getPixel(0, 0);
    }/*  ww  w  .  j  a v  a  2 s .c  om*/
    return getHighlightColor(incolor);
}

From source file:Main.java

public static int getAverageColor(@NonNull Bitmap bitmap) {
    Bitmap onePixelBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
    int color = onePixelBitmap.getPixel(0, 0);
    onePixelBitmap.recycle();//from  w  ww.  j a v  a  2  s . co m
    return color;
}

From source file:Main.java

public static String getARGBstring(Bitmap bitmap, int x, int y) {
    return "ARGB at " + x + "," + y + " is \t\tA " + String.format("%03d", Color.alpha(bitmap.getPixel(x, y)))
            + "\t\tR " + String.format("%03d", Color.red(bitmap.getPixel(x, y))) + "\t\tG "
            + String.format("%03d", Color.green(bitmap.getPixel(x, y))) + "\t\tB "
            + String.format("%03d", Color.blue(bitmap.getPixel(x, y)));
}