我只能旋转图像一次,当我再次点击按钮时,图像冻结,不旋转。请帮帮我。matrix.postRotate(90)在图像旋转
try{
//Bitmap bMap;
//Get ImageView from layout xml file
img = (ImageView) findViewById(R.id.imageView01);
//Decode Image using Bitmap factory.
Bitmap bMap = BitmapFactory.decodeFile(selectedImagePath);
//Create object of new Matrix.
Matrix matrix = new Matrix();
//set image rotation value to 90 degrees in matrix.
matrix.postRotate(90);
//Create bitmap with new values.
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(), bMap.getHeight(), matrix, true);
//put rotated image in ImageView.
img.setImageBitmap(bMapRotate);
Context context = getApplicationContext();
CharSequence text = "Image Rotated" ;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}catch (Exception e) {
e.printStackTrace();
displayExceptionMessage(e.getMessage());
}
在这里,可以旋转的下一个时间已旋转的图像,而不是原来的图像,它不会在旋转的原始图像的任何影响试。 – Hardik4560 2013-05-08 09:23:41
我必须从imageView中获取图像并再次旋转它吗?但如何..你可以请让我看看,因为我是Android新手。谢谢 – chai 2013-05-08 09:25:30
这取决于你到底想要达到什么目标,从imageView获取图像将是一个更好的选择。 – Hardik4560 2013-05-08 09:29:21