private Bitmap reSize(Bitmap bitmaporg) {    int widthold = bitmaporg.getWidth();//eg:1024    int heightold = bitmaporg.getHeight();//eg:819    //获取屏幕的宽高    DisplayMetrics dm = new DisplayMetrics();    getWindowManager().getDefaultDisplay().getMetrics(dm);    int screenWidth = dm.widthPixels;  //eg:1440    int screenHeigh = dm.heightPixels;  //eg:2392    float density = dm.density;  // 密度(0.75 / 1.0 / 1.5 //eg: 1dp=3.5px    //int densityDpi = dm.densityDpi;  // 密度DPI120 / 160 / 240    float scale = (float) screenWidth / ((density + 0.2f) * widthold);    Matrix matrix = new Matrix();    if (scale < 1) {        //将大图缩小至适屏        float scaleWidth = (float) scale;        float scaleHeight = (float) scale;        matrix.postScale(scaleWidth, scaleHeight);    } else {        float scaleWidth = 1;        float scaleHeight = 1;        matrix.postScale(scaleWidth, scaleHeight);    }    Log.d("Main", "screenWidth:" + screenWidth);    Log.d("Main", "screenHeight:" + screenHeigh);    Log.d("Main", "widthold:" + widthold);    Log.d("Main", "heightold:" + heightold);    Bitmap bitmapnew = Bitmap.createBitmap(bitmaporg, 0, 0, widthold, heightold, matrix, true);    int widtnew = bitmapnew.getWidth();    int heightnew = bitmapnew.getHeight();    Log.d("Main", "widthnew:" + widtnew);    Log.d("Main", "heightnew:" + heightnew);    return bitmapnew;}

更多相关文章

  1. Android手机开发:图片的放大和缩小显示ImageView
  2. android中dp和px的转换
  3. [置顶] 我的Android进阶之旅------>android Matrix图片随意的放
  4. Android(安卓)图片预览模仿朋友圈查看图片效果放大图片,左右滑动
  5. Android(安卓)支持多屏幕机制
  6. 如何实现Android(安卓)布局背景模糊化处理
  7. 如何实现Android(安卓)布局背景模糊化处理
  8. Android高效加载大图、多图解决方案,有效避免程序OOM
  9. 【转】Android(安卓)图标规格

随机推荐

  1. Android Wear 进阶 5 - Creating Watch F
  2. http请求No peer certificate的解决方法
  3. Android(安卓)4.2.2 ScreenLock上Music远
  4. Android Studio问题之dexDebug
  5. Android 自定义日期控件,包含月控件
  6. android 自定义dialog弹出和消失缩放动画
  7. Android Spinner控件之键值对用法
  8. OpenFrameworks + kinect + Android项目
  9. 《Android(安卓)UI基础教程》之读书笔记
  10. ANDROID NDK使用第三方静态库的方法