我只能旋轉圖像一次,當我再次點擊按鈕時,圖像凍結,不旋轉。請幫幫我。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