List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:Main.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, final float roundPx) { if (bitmap == null) return null; try {/* ww w . j a v a2 s . c om*/ Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight())); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); final Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawBitmap(bitmap, src, rect, paint); return output; } catch (Exception e) { return bitmap; } }
From source file:Main.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { try {//from w w w . j av a 2s. co m Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight())); final float roundPx = 15; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); final Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawBitmap(bitmap, src, rect, paint); return output; } catch (Exception e) { return bitmap; } }
From source file:Main.java
public static Bitmap GetRoundedCornerBitmap(Bitmap bitmap) { try {//from ww w. j av a 2 s.c o m Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight())); final float roundPx = 14; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); final Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawBitmap(bitmap, src, rect, paint); return output; } catch (Exception e) { return bitmap; } }
From source file:Main.java
public static void drawShade(Canvas canvas, RectF bounds) { int w = canvas.getWidth(); int h = canvas.getHeight(); Paint p = new Paint(); p.setStyle(Paint.Style.FILL); p.setColor(Color.BLACK & 0x88000000); RectF r = new RectF(); r.set(0, 0, w, bounds.top);// w w w. ja v a2 s . com canvas.drawRect(r, p); r.set(0, bounds.top, bounds.left, h); canvas.drawRect(r, p); r.set(bounds.left, bounds.bottom, w, h); canvas.drawRect(r, p); r.set(bounds.right, bounds.top, w, bounds.bottom); canvas.drawRect(r, p); }
From source file:Main.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int backgroundColor, int borderColor) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth() + 12, bitmap.getHeight() + 12, Bitmap.Config.ARGB_8888);// w ww .j a va 2 s. c o m Canvas canvas = new Canvas(output); //canvas.drawARGB(Color.alpha(backgroundColor), Color.red(backgroundColor), Color.green(backgroundColor), Color.blue(backgroundColor)); Paint borderPaint = new Paint(); borderPaint.setAntiAlias(true); borderPaint.setColor(borderColor); borderPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); borderPaint.setShadowLayer(2.0f, 0.0f, 2.0f, Color.BLACK); int centerWidth = output.getWidth() / 2; int centerHeight = output.getHeight() / 2; canvas.drawCircle(centerWidth, centerHeight, ((centerWidth + centerHeight) / 2) - 4, borderPaint); Paint paint = new Paint(); paint.setAntiAlias(true); Rect rectS = new Rect(0, 0, output.getWidth() - 12, output.getHeight() - 12); Rect rectD = new Rect(0, 0, output.getWidth(), output.getHeight()); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(bitmap, rectS, rectD, paint); return output; }
From source file:Main.java
public static int color(int color) { float r = Color.red(color) + 1; float g = Color.green(color) + 1; float b = Color.blue(color) + 1; if (2 * g >= 3 * r && g / b >= 2) return GREEN; if (r / g > 4 && r / b > 4) return RED; if (r / b >= 3 && g / b >= 2 && r > g * 1.2) return ORANGE; // at Sytadin, yellow stands for 'works', lets consider green if (r > 150 && g > 150 && b < 50) return GREEN; if (r / b > 0.8 && r / b < 1.3 && g / b > 0.8 && g / b < 1.3) return GRAY; // Log.e(tag, "Warn : nok color extraction for: " + color + ". r : " + r +", g : " +g +", b : " + b); return Color.BLACK; }
From source file:Main.java
/** * Create a rounded corner bitmap from current bitmap * * @param bitmap//from w w w .j av a2s . co m * @return */ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { try { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight())); final float roundPx = 50; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); final Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawBitmap(bitmap, src, rect, paint); return output; } catch (Exception e) { return bitmap; } }
From source file:Main.java
/** * @param bitmap Bitmap that will be processed * @return The average color of the input bitmap *//*from w w w . j a v a 2s . c o m*/ public static int getAverageColor(Bitmap bitmap) { if (bitmap == null) { Log.e("getAverageColor()", "ERROR: No bitmap generated to get average colour from."); return Color.BLACK; } int redBucket = 0; int greenBucket = 0; int blueBucket = 0; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int pixelCount = 0; int c = 0; for (int y = 0; y < height; y += STEP_SIZE_PIXEL) { for (int x = 0; x < width; x += STEP_SIZE_PIXEL) { c = bitmap.getPixel(x, y); redBucket += Color.red(c); greenBucket += Color.green(c); blueBucket += Color.blue(c); pixelCount++; } redBucket += Color.red(c); } return Color.rgb(redBucket / pixelCount, greenBucket / pixelCount, blueBucket / pixelCount); }
From source file:Main.java
public static Bitmap forceConfig565(Bitmap original) { Bitmap convertedBitmap = original;/* w w w . j ava2 s.c om*/ if (original.getConfig() != Bitmap.Config.RGB_565) { convertedBitmap = Bitmap.createBitmap(original.getWidth(), original.getHeight(), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(convertedBitmap); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(original, 0, 0, paint); if (convertedBitmap != original) { original.recycle(); } } return convertedBitmap; }
From source file:Main.java
@Deprecated public static int getContrastYIQ(int color, int threshold) { return getContrastYIQ(color, threshold, Color.BLACK, Color.WHITE); }