小智 14
您始终可以通过Bitmap.createBitmap()静态方法裁剪所需的部分,然后将其分配给视图:
就像是...
// Set some constants
private static final Bitmap SOURCE_BITMAP = BitmapFactory.decodeFile(....); // Get the source Bitmap using your favorite method :-)
private static final int START_X = 10;
private static final int START_Y = 15;
private static final int WIDTH_PX = 100;
private static final int HEIGHT_PX = 100;
// Crop bitmap
Bitmap newBitmap = Bitmap.createBitmap(SOURCE_BITMAP, START_X, START_Y, WIDTH_PX, HEIGHT_PX, null, false);
// Assign new bitmap to ImageView
ImageView image = (ImageView)findViewById(R.id.image_view);
image.setImageBitmap(newBitmap);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8224 次 |
| 最近记录: |