Notice
Recent Posts
Recent Comments
Link
관리 메뉴

설.현.아빠

Resize and rotate Bitmap image 본문

안드로이드/Image

Resize and rotate Bitmap image

설.현.아빠 2011. 2. 11. 10:38


이미지 크기를 줄인후 45도로 회전시키기

 

// load the origial BitMap (500 x 500 px) 
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.android); 

int width = bitmapOrg.width(); 
int height = bitmapOrg.height(); 
int newWidth = 200; 
int newHeight = 200; 

// calculate the scale - in this case = 0.4f 
float scaleWidth = ((float) newWidth) / width; 
float scaleHeight = ((float) newHeight) / height; 

// 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); 

 

http://rsequence.com/android_blog/node/136

Comments