public static Bitmap decodeBitmap(Context context,int id,int scaleWidth,int scaleHeight){
BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds=true;//表示只加载图片边缘的信息
BitmapFactory.decodeResource(context.getResources(), id,options);
int height=options.outHeight;
int width=options.outWidth;
int newheight=height/scaleHeight;
int newwidth=width/scaleWidth;
Log.e(TAG, "decodeBitmap: newheight+"+newheight+"newwidth="+ newwidth);
options.inSampleSize=newheight<newwidth?newheight:newwidth;
options.inJustDecodeBounds=false;
options.inPreferredConfig=Bitmap.Config.ARGB_8888;
return BitmapFactory.decodeResource(context.getResources(), id,options);
}
Bitmap图片缩放处理
最新推荐文章于 2022-11-05 10:32:24 发布