图形处理

3.4.1 ColorMatrix

Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(imageFileUri),null,bmpFactoryOptions);

Bitmap alterBitmap=Bitmap.createBitmap(bmp.getWidth(),bmp.getHieght(),bmp.getConfig());

Canvas canvas=new Canvas(alterBitmap);

Paint paint=new Paint();

ColorMatrix cm=new ColorMatrix();

paint.setColorFIlter(new ColorMatrixColorFilter(cm));

Matrix matrix=new Matrix();

canvas.drawBitmap(bmp,matrix,paint);

alteredImageView.setImageBitmap(alteredBItmap);

chosenImageView.setImageBItmap(bmp);

3.4.2 改变对比度和亮度

 通过增加或减少颜色值调整图形的亮度和对比度

  ColorMatrix cm=new ColorMatrix();

  float contrast=2;

  cm.set(new float[]{constrast,0,0,0,0,};

 paint.setColorFilter(new ColorMatrixColorFilter(cm));

3.5 图形合成
paint.setXfermode(new PorterDuffxfermode(android.graphics.PorterDuff.Mode.MULTIPLY));



你可能感兴趣的:(Android多媒体开发)