List of usage examples for android.graphics ColorMatrix postConcat
public void postConcat(ColorMatrix postmatrix)
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);//from w w w. ja va 2s. co m hueMatrix.setRotate(1, hue); 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:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static void setBackground(View v, Bitmap bm) { if (bm == null) { v.setBackgroundResource(0);/* w w w.jav a 2 s . c o m*/ return; } int vwidth = v.getWidth(); int vheight = v.getHeight(); int bwidth = bm.getWidth(); int bheight = bm.getHeight(); float scalex = (float) vwidth / bwidth; float scaley = (float) vheight / bheight; float scale = Math.max(scalex, scaley) * 1.3f; Bitmap.Config config = Bitmap.Config.ARGB_8888; Bitmap bg = Bitmap.createBitmap(vwidth, vheight, config); Canvas c = new Canvas(bg); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setFilterBitmap(true); ColorMatrix greymatrix = new ColorMatrix(); greymatrix.setSaturation(0); ColorMatrix darkmatrix = new ColorMatrix(); darkmatrix.setScale(.3f, .3f, .3f, 1.0f); greymatrix.postConcat(darkmatrix); ColorFilter filter = new ColorMatrixColorFilter(greymatrix); paint.setColorFilter(filter); Matrix matrix = new Matrix(); matrix.setTranslate(-bwidth / 2, -bheight / 2); // move bitmap center to origin matrix.postRotate(10); matrix.postScale(scale, scale); matrix.postTranslate(vwidth / 2, vheight / 2); // Move bitmap center to view center c.drawBitmap(bm, matrix, paint); v.setBackgroundDrawable(new BitmapDrawable(bg)); }
From source file:com.derrick.movies.MovieDetailsActivity.java
private ColorMatrix geColorMatrix() { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(2);//from www .j ava 2s. co m ColorMatrix colorScale = new ColorMatrix(); colorScale.setScale(1, 1, 0.8f, 1); colorMatrix.postConcat(colorScale); return colorMatrix; }