可以在Android中剪切图像吗?似乎我找不到它的任何教程。
答案 0 :(得分:2)
也许您已经找到了解决方案,但为了以防万一,我认为这就是您所需要的:
Bitmap src = BitmapFactory.decodeResource(this.getResources(), drawable.sample);
int width = src.getWidth();
int height = src.getHeight();
float skewX = 5.0;
float skewY = 6.0;
Matrix matrix = new Matrix();
matrix.setSkew(skewX, skewY);
Bitmap img = Bitmap.createBitmap(src, 0, 0, width, height, matrix, true);
答案 1 :(得分:0)
这可以帮助你
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.flower_blue);
Bitmap croppedBmp = Bitmap.createBitmap(bitmapOrg, 0, 0,
bitmapOrg.getWidth() / 2, bitmapOrg.getHeight());
int h = bitmapOrg.getHeight();
canvas.drawBitmap(bitmapOrg, 10, 10, paint);
canvas.drawBitmap(croppedBmp, 10, 10 + h + 10, paint);