我有一個矩形尺寸的圖像,例如30 x 60像素 我想旋轉此圖像圍繞圖像的底部中心,即 我想在上面設置樞軸例如(15,60)像素。旋轉圖像aroound點
我使用一個繪圖和矩陣來完成這個任務, 無論我嘗試我總是最終圍繞圖像中心旋轉。
代碼是:
Bitmap bitmapOrg = BitmapFactory.decodeFile("/sdcard/DCIM/2010-06-01_15-32-42_821.jpg");
//浮動角=(角度+ 10.0f)%360.0f; 如果(空= bitmapOrg!) {
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
int newWidth = 15;
int newHeight = 15;
// calculate the scale - in this case = 0.4f
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
/*帆布C =新畫布(bitmapOrg); float px =; float py; c.rotate(角度,PX,PY)*/
// createa matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// rotate the Bitmap
// matrix.postRotate(45);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
width, height, matrix, true);
// make a Drawable from Bitmap to allow to set the BitMap
// to the ImageView, ImageButton or what ever
BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
ImageView imageView = new ImageView(this);
// set the Drawable on the ImageView
imageView.setImageDrawable(bmd);
// center the Image
imageView.setScaleType(ScaleType.CENTER);
// imageView.layout(100,300,0,0); // linLayout.addView(imageView);
// add ImageView to the Layout
linLayout.addView(imageView,
new AbsoluteLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 10, 30
)
);
任何人都可以讓我知道如何得到這個糾正?
上面的網址缺失... – RRTW 2013-01-30 07:01:50
這還不是3歲。 我字面上去了網站,並從破碎的鏈接搜索關鍵字: http://developer.sonymobile.com/2010/05/31/android-tutorial-making-your-own-3d-list-part- 2 / – 2013-01-31 00:44:00