Java Code Examples for android.graphics.ColorMatrix#getArray()
The following examples show how to use
android.graphics.ColorMatrix#getArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPickerDialog.java From AndroidDrawing with MIT License | 6 votes |
private int rotateColor(int color, float rad) { float deg = rad * 180 / 3.1415927f; int r = Color.red(color); int g = Color.green(color); int b = Color.blue(color); ColorMatrix cm = new ColorMatrix(); ColorMatrix tmp = new ColorMatrix(); cm.setRGB2YUV(); tmp.setRotate(0, deg); cm.postConcat(tmp); tmp.setYUV2RGB(); cm.postConcat(tmp); final float[] a = cm.getArray(); int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b); int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b); int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b); return Color.argb(Color.alpha(color), pinToByte(ir), pinToByte(ig), pinToByte(ib)); }
Example 2
Source File: ColorPickerDialog.java From geopaparazzi with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") private int rotateColor(int color, float rad) { float deg = rad * 180 / 3.1415927f; int r = Color.red(color); int g = Color.green(color); int b = Color.blue(color); ColorMatrix cm = new ColorMatrix(); ColorMatrix tmp = new ColorMatrix(); cm.setRGB2YUV(); tmp.setRotate(0, deg); cm.postConcat(tmp); tmp.setYUV2RGB(); cm.postConcat(tmp); final float[] a = cm.getArray(); int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b); int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b); int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b); return Color.argb(Color.alpha(color), pinToByte(ir), pinToByte(ig), pinToByte(ib)); }
Example 3
Source File: FastBitmapDrawable.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
private static void setBrightnessMatrix(ColorMatrix matrix, int brightness) { // Brightness: C-new = C-old*(1-amount) + amount float scale = 1 - brightness / 255.0f; matrix.setScale(scale, scale, scale, 1); float[] array = matrix.getArray(); // Add the amount to RGB components of the matrix, as per the above formula. // Fifth elements in the array correspond to the constant being added to // red, blue, green, and alpha channel respectively. array[4] = brightness; array[9] = brightness; array[14] = brightness; }
Example 4
Source File: FastBitmapDrawable.java From FastAccess with GNU General Public License v3.0 | 5 votes |
private static void setBrightnessMatrix(ColorMatrix matrix, int brightness) { // Brightness: C-new = C-old*(1-amount) + amount float scale = 1 - brightness / 255.0f; matrix.setScale(scale, scale, scale, 1); float[] array = matrix.getArray(); // Add the amount to RGB components of the matrix, as per the above formula. // Fifth elements in the array correspond to the constant being added to // red, blue, green, and alpha channel respectively. array[4] = brightness; array[9] = brightness; array[14] = brightness; }
Example 5
Source File: FastBitmapDrawable.java From LB-Launcher with Apache License 2.0 | 5 votes |
private static void setBrightnessMatrix(ColorMatrix matrix, int brightness) { // Brightness: C-new = C-old*(1-amount) + amount float scale = 1 - brightness / 255.0f; matrix.setScale(scale, scale, scale, 1); float[] array = matrix.getArray(); // Add the amount to RGB components of the matrix, as per the above formula. // Fifth elements in the array correspond to the constant being added to // red, blue, green, and alpha channel respectively. array[4] = brightness; array[9] = brightness; array[14] = brightness; }
Example 6
Source File: ColorMatrices.java From cathode with Apache License 2.0 | 5 votes |
static void setContrast(ColorMatrix colorMatrix, float contrast) { float translate = (1f - contrast) / 2f; float[] array = colorMatrix.getArray(); array[ROW_RED + COLUMN_RED] = contrast; array[ROW_GREEN + COLUMN_GREEN] = contrast; array[ROW_BLUE + COLUMN_BLUE] = contrast; array[ROW_RED + COLUMN_TRANSLATE] = translate; array[ROW_GREEN + COLUMN_TRANSLATE] = translate; array[ROW_BLUE + COLUMN_TRANSLATE] = translate; }