以下のコードを使用して、キャンバスを使用して円の中心にその画像を描画しています。
Bitmap bitmapCompass = BitmapFactory.decodeResource(getResources(), R.drawable.compass_rim);
float w2= (w-bitmapCompass.getWidth())/2;
float h2= (h-bitmapCompass.getHeight())/2;
canvas.drawBitmap(bitmapCompass, w2, h2, paint);
この画像をダイヤラーのように中心を基準にして回転させたい.直面している問題は、その円の中心を中心に画像を回転させることです。
ローテーションに使用されるコード:
Bitmap bitmapCompass = BitmapFactory.decodeResource(getResources(), R.drawable.compass_back);
float w2= (w-bitmapCompass.getWidth())/2;
float h2= (h-bitmapCompass.getHeight())/2;
Matrix matbitmapCompass = new Matrix();
matbitmapCompass.postRotate((float)90);
Bitmap bmpRotateCompass = Bitmap.createBitmap(bitmapCompass, 0,0, bitmapCompass.getWidth(), bitmapCompass.getHeight(), matbitmapCompass, true);
canvas.drawBitmap(bmpRotateCompass, w2, h2, paint);
助けていただければ幸いです。
ありがとう