Example usage for android.graphics Color rgb

List of usage examples for android.graphics Color rgb

Introduction

In this page you can find the example usage for android.graphics Color rgb.

Prototype

@ColorInt
public static int rgb(float red, float green, float blue) 

Source Link

Document

Return a color-int from red, green, blue float components in the range \([0..1]\).

Usage

From source file:Main.java

public static int RGBToColor(final double pRed, final double pGreen, final double pBlue) {
    Log.d("ColorUtils", "Before Scan= " + pRed + ", " + pGreen + " , " + pBlue);

    return Color.rgb(normalizeDouble(pRed), normalizeDouble(pGreen), normalizeDouble(pBlue));
}

From source file:Main.java

public static int colorBurn(int RGBValues) {
    int alpha = RGBValues >> 24;
    int red = RGBValues >> 16 & 0xFF;
    int green = RGBValues >> 8 & 0xFF;
    int blue = RGBValues & 0xFF;
    red = (int) Math.floor(red * (1 - 0.1));
    green = (int) Math.floor(green * (1 - 0.1));
    blue = (int) Math.floor(blue * (1 - 0.1));
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int blendColors(int color1, int color2, float percent) {
    float inverseRation = 1 - percent;
    float r = Color.red(color1) * percent + Color.red(color2) * inverseRation;
    float g = Color.green(color1) * percent + Color.green(color2) * inverseRation;
    float b = Color.blue(color1) * percent + Color.blue(color2) * inverseRation;
    return Color.rgb((int) r, (int) g, (int) b);
}

From source file:Main.java

public static int blendColors(int color1, int color2, float ratio) {
    final float inverseRatio = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRatio);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRatio);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRatio);
    return Color.rgb((int) r, (int) g, (int) b);
}

From source file:Main.java

/**
 * Calculate the value for different color.
 *
 * @param baseColor Value of base color.
 * @param level Level.// ww  w  .j  a  va 2s . co m
 * @return The value for the level of the base color.
 */
public static int calculateLevelColor(int baseColor, int level) {
    return Color.rgb(calculateR(Color.red(baseColor), level), calculateG(Color.green(baseColor), level),
            calculateB(Color.blue(baseColor), level));
}

From source file:Main.java

public static int mix(int color1, int color2) {
    int r1 = Color.red(color1);
    int g1 = Color.green(color1);
    int b1 = Color.blue(color1);
    int r2 = Color.red(color2);
    int g2 = Color.green(color2);
    int b2 = Color.blue(color2);
    int r3 = (int) ((r1 + r2) * 0.5);
    int g3 = (int) ((g1 + g2) * 0.5);
    int b3 = (int) ((b1 + b2) * 0.5);
    return Color.rgb(r3, g3, b3);
}

From source file:Main.java

public static int blendColors(int color1, int color2, float ratio) {
    float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
}

From source file:Main.java

public static int blendColors(int color1, int color2, float ratio) {
    final float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
}

From source file:Main.java

public static void setViewTouchHightlighted(final View view) {
    if (view == null) {
        return;/*from  www.j a v  a  2  s  . c  om*/
    }

    view.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                view.setBackgroundColor(Color.rgb(1, 175, 244));
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                view.setBackgroundColor(Color.rgb(255, 255, 255));
            }
            return false;
        }
    });
}

From source file:Main.java

/**
 * Draw the face rect in the Image// w  ww .ja  v a2s .  c  om
 * @param canvas
 * @param face
 * @param width
 * @param height
 * @param frontCamera
 */
static public void drawFaceRect(Canvas canvas, Rect rect, int width, int height, boolean frontCamera) {

    if (canvas == null)
        return;

    Paint paint = new Paint();
    paint.setColor(Color.rgb(57, 138, 243));
    int len = (rect.bottom - rect.top) / 8;
    if (len / 8 >= 2)
        paint.setStrokeWidth(len / 8);
    else
        paint.setStrokeWidth(2);

    if (frontCamera) {
        int left = rect.left;
        rect.left = width - rect.right;
        rect.right = width - left;
    }

    paint.setStyle(Style.STROKE);
    canvas.drawRect(rect, paint);
}