图片的合成_改变图片颜色形成老照片水彩画效果
就是利用ColorMatrx来进行改变
1 @Override 2 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 3 try { 4 if (data != null) { 5 // 得到点击图片的uri 6 Uri uri = data.getData(); 7 //原图 8 Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri)); 9 iv.setImageBitmap(bitmap); 10 //原图的拷贝 11 Bitmap alterBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight()-30, bitmap.getConfig()); 12 //以拷贝图片的为模板创建一个画布 13 Canvas canvas = new Canvas(alterBitmap); 14 Matrix matrix = new Matrix(); 15 16 ColorMatrix cm = new ColorMatrix(); 17 /* cm.set(new float[] { 18 1, 3, 0, 0, 0, 19 0, 2, 0, 0, 0, 20 0, 0, 3, 0, 0, 21 0, 0, 0, 1, 0 22 });*/ 23 cm.setSaturation(0.5f); 24 25 26 27 28 Paint paint = new Paint(); 29 paint.setColorFilter(new ColorMatrixColorFilter(cm)); 30 31 paint.setAntiAlias(true);//在算法上 取消锯齿 32 canvas.drawBitmap(bitmap, matrix, paint); 33 iv_copy.setImageBitmap(alterBitmap); 34 } 35 } catch (FileNotFoundException e) { 36 e.printStackTrace(); 37 } 38 super.onActivityResult(requestCode, resultCode, data); 39 }