我正在尝试裁剪和缩放给定的位图,但只有缩放有效。
我究竟做错了什么?
private Bitmap CropAndShrinkBitmap(Bitmap io_BitmapFromFile, int i_NewWidth, int i_NewHeight)
{
int cuttingOffset = 0;
int currentWidth = i_BitmapFromFile.getWidth();
int currentHeight = i_BitmapFromFile.getHeight();
if(currentWidth > currentHeight)
{
cuttingOffset = currentWidth - currentHeight;
Bitmap.createBitmap(i_BitmapFromFile, cuttingOffset/2, 0, currentWidth - cuttingOffset, currentHeight);
}
else
{
cuttingOffset = i_NewHeight - currentWidth;
Bitmap.createBitmap(i_BitmapFromFile, 0, cuttingOffset/2, currentWidth, currentHeight - cuttingOffset);
}
Bitmap fixedBitmap = Bitmap.createScaledBitmap(i_BitmapFromFile, i_NewWidth, i_NewHeight, false) ;
return i_BitmapFromFile;
}
描述说:“createBitmap 返回一个不可变的位图”。
那什么意识?这是我问题的原因吗?