List of usage examples for android.graphics ColorMatrix setRotate
public void setRotate(int axis, float degrees)
From source file:Main.java
public static Bitmap handleImageEffect(Bitmap bm, float hue, float saturation, float lum) { Bitmap bmp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); ColorMatrix hueMatrix = new ColorMatrix(); hueMatrix.setRotate(0, hue); hueMatrix.setRotate(1, hue);/*from w w w . java 2 s . c o m*/ hueMatrix.setRotate(2, hue); ColorMatrix saturationMatrix = new ColorMatrix(); saturationMatrix.setSaturation(saturation); ColorMatrix lumMatrix = new ColorMatrix(); lumMatrix.setScale(lum, lum, lum, 1); ColorMatrix imageMatrix = new ColorMatrix(); imageMatrix.postConcat(hueMatrix); imageMatrix.postConcat(saturationMatrix); imageMatrix.postConcat(lumMatrix); paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix)); canvas.drawBitmap(bm, 0, 0, paint); return bmp; }
From source file:com.yk.notification.util.BitmapUtil.java
/** * ?/*from www . j a v a 2 s .co m*/ * * @param bitmap * * @param hueValue * * @return ?? */ public static Bitmap hue(Bitmap bitmap, int hueValue) { // ?? float newHueValue = (hueValue - 127) * 1.0F / 127 * 180; // ColorMatrix hueColorMatrix = new ColorMatrix(); // hueColorMatrix.setRotate(0, newHueValue); // hueColorMatrix.setRotate(1, newHueValue); // ? hueColorMatrix.setRotate(2, newHueValue); // Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(hueColorMatrix)); // Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); // canvas.drawBitmap(bitmap, 0, 0, paint); return newBitmap; }
From source file:com.yk.notification.util.BitmapUtil.java
/** * ???/*from ww w . ja va 2 s .c om*/ * * @param bitmap * * @param lumValue * * @param hueValue * * @param saturationValue * * @return ???? */ public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue, int hueValue, int saturationValue) { // ?? float newSaturationValue = saturationValue * 1.0F / 127; // ?? float newlumValue = lumValue * 1.0F / 127; // ?? float newHueValue = (hueValue - 127) * 1.0F / 127 * 180; // ColorMatrix colorMatrix = new ColorMatrix(); // colorMatrix.setSaturation(newSaturationValue); // colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1); // colorMatrix.setRotate(0, newHueValue); // colorMatrix.setRotate(1, newHueValue); // ? colorMatrix.setRotate(2, newHueValue); // Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); // Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); // canvas.drawBitmap(bitmap, 0, 0, paint); return newBitmap; }