绘制

依据某一种颜色绘制Bitmap

Bitmap resultBitmap = Bitmap.createBitmap(600,800,Bitmap.Config.ARGB_8888);
resultBitmap.eraseColor(Color.WHITE);

裁剪

1

bitmap = bitmap.createBitmap(bitmap,0,70,bitmap.getWidth(),bitmap.getHeight()/3);

2

用Matrix来改变裁剪图片的寬高

Matrix matrix = new Matrix();
matrix.postScale(2.0f, 0.5f); 
bitmap = bitmap.createBitmap(bitmap,0,0,bitmap.getWidth()/2,bitmap.getHeight(),matrix,false);

3

Bitmap resultBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawColor(0xfff2f2f2);
Rect srcMask = new Rect(0, 0, thumbnail.getWidth()*3/5, thumbnail.getHeight());
Rect dstMask = new Rect(0, 0, width, height*3/5);
canvas.drawBitmap(thumbnail,srcMask, dstMask, null);
bmp = resultBitmap;
posted on 2017-08-09 14:27  lxjshuju  阅读(293)  评论(0编辑  收藏  举报