Bitmap图片缩放处理

来源:互联网 发布:access数据库编辑器 编辑:程序博客网 时间:2024/05/22 04:27
 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);    }

0 0
原创粉丝点击