public class ScalePhoto {
public ScalePhoto() {
// TODO Auto-generated constructor stub
}
public static Bitmap scale(Bitmap input,int width, int height)
{
int w = input.getWidth();
int h = input.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) width / w);
float scaleHeight = ((float) height / h);
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(input, 0, 0, w, h, matrix, true);
}
}
格式化
廣告
文章分類
廣告2
2012年11月20日 星期二
[Android程式範例] 利用Matrix類別對Bitmap圖片放大或縮小
訂閱:
張貼留言
(
Atom
)

沒有留言 :
張貼留言