我试图通过使用createScaledBitmap使方块更大。但是,正方形变成宽度比高度长的矩形。为保持纵横比不变,采用这种方法的正确方法是什么?
public Bitmap getScaledBitmap(Bitmap bitmap){
dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
scaledBitmapW = (int)(dm.widthPixels/(10)); *//make the square just 1/10 of the screen width*
scaledBitmapH = (int)(scaledBitmapW*(bitmap.getHeight()/bitmap.getWidth()));
scaledBitmap = Bitmap.createScaledBitmap(bitmap, scaledBitmapW, scaledBitmapH, true);
return scaledBitmap;
}