길이가 30 x 60 픽셀 인 이미지가 있습니다. 위 이미지를 이미지의 아래쪽 중심 주위로 회전하고 싶습니다. 예 : 위의 피벗을 설정하고 싶습니다. 예 : (15, 60) 픽셀.이미지 회전 지점
나는 이것을하기 위해 drawble과 matrix를 사용하고 있는데, 무엇이든 나는 항상 이미지 중심을 중심으로 회전한다.
코드 :
Bitmap bitmapOrg = BitmapFactory.decodeFile("/sdcard/DCIM/2010-06-01_15-32-42_821.jpg");
// 플로트 각도 = (각도 + 10.0f) 360.0f %; (! = null의 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
)
);
아무도 내가이 정류 방법을 알 수 있습니까?
위의 URL이 누락되었습니다 ... – RRTW
이것은 3 년되지 않았습니다. 나는 문자 그대로 사이트에 가서 깨진 링크에서 키워드를 검색했다 : http://developer.sonymobile.com/2010/05/31/android-tutorial-making-your-own-3d-list-part- 2 / –