我想從Android的中心點放大位圖以實現縮放效果,但沒有成功。我的代碼是:從Android的中心點縮放位圖以進行放大效果
float scaleWidth = ((float) width + (i * 5))/width;
float scaleHeight = ((float) height + (i * 5))/height;
Matrix matrix = new Matrix();
matrix.setScale(scaleWidth, scaleHeight, scaleWidth/2, scaleHeight/2);
Bitmap rescaledBitmap = Bitmap.createBitmap(src, 0, 0, width, height, matrix, true);
result.add(rescaledBitmap);
我除以2的尺寸設置樞轉點,但效果是僅僅該圖像是從0縮放,0作爲代替的座標從中心。我想要的是圖像是一個固定的大小,但從中心點放大(從而裁剪圖像)。
那豈不是更容易使用Bitmap類的createScaledBitmap? http://developer.android.com/reference/android/graphics/Bitmap.html#createScaledBitmap(android.graphics.Bitmap,int,int,boolean) –
試過嗎? http://stackoverflow.com/a/5286749/2074990 – bofredo
@Pawel將重新調整圖像大小,我只是想放大,而使用相同的圖像大小。我的問題不是很清楚,會更新它。 – n83