android bitmap的放大缩小
转载
private static Bitmap big(Bitmap bitmap) {
Matrix matrix = new Matrix();
matrix.postScale(1.5f,1.5f); //长和宽放大缩小的比例
Bitmap resizeBmp = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
return resizeBmp;
}
private static Bitmap small(Bitmap bitmap) {
Matrix matrix = new Matrix();
matrix.postScale(0.8f,0.8f); //长和宽放大缩小的比例
Bitmap resizeBmp = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
return resizeBmp;
}
android中Canvas使用drawBitmap绘制图片
- //Bitmap:图片对象,left:偏移左边的位置,top: 偏移顶部的位置
-
- drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
2、对图片剪接和限定显示区域
- drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint);
- Rect src: 是对图片进行裁截,若是空null则显示整个图片
- RectF dst:是图片在Canvas画布中显示的区域,
-
- 大于src则把src的裁截区放大,
-
- 小于src则把src的裁截区缩小。