如何在上载到db时减小捕获的图像大小,上载需要花费很多时间,上载需要花费很多时间。请帮助我解决这一问题,如何将图像调整为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);
}
忘掉所有的东西。
只是做这个
Bitmap yourBitmap;
resized = Bitmap.createScaledBitmap(yourBitmap,(int)(yourBitmap.getWidth()*0.8), (int)(yourBitmap.getHeight()*0.8), true);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句