如何在上传到数据库时减少捕获的图像大小,上传需要花费很多时间,下载时间也是如此。请帮我这个,如何将图像调整为100kb ..快速帮助我。
public Bitmap getResizedBitmap(Bitmap myBitmap) {
final int maxSize = 1024;
int outWidth;
int outHeight;
int inWidth = myBitmap.getWidth();
int inHeight = myBitmap.getHeight();
if (inWidth > inHeight) {
outWidth = maxSize;
outHeight = (inHeight * maxSize) / inWidth;
} else {
outHeight = maxSize;
outWidth = (inWidth * maxSize) / inHeight;
}
return Bitmap.createScaledBitmap(myBitmap, outWidth, outHeight, false);
}
答案 0 :(得分:0)
忘记所有事情。
就这样做
Bitmap yourBitmap;
resized = Bitmap.createScaledBitmap(yourBitmap,(int)(yourBitmap.getWidth()*0.8), (int)(yourBitmap.getHeight()*0.8), true);