当前位置: 代码迷 >> Android >> Android图片大小曲整动态实现主要代码
  详细解决方案

Android图片大小曲整动态实现主要代码

热度:9   发布时间:2016-05-01 16:18:04.0
Android图片大小调整动态实现主要代码
view plaincopy to clipboardprint?  private Bitmap getImageFromAssetFile(String fileName,int how){       Bitmap image = null ;      try {             AssetManager am = game.getAssets();              InputStream is = am.open(fileName);             image = BitmapFactory.decodeStream(is);             is.close();          }catch (Exception e){   }      return zoomImage(image,how);    }    public Bitmap zoomImage(Bitmap bgimage,int how) {         int bmpwidth = bgimage.getWidth();         int bmpheight = bgimage.getHeight();          float scaleWidth=0;          float scaleHeight=0;          Matrix matrix = new Matrix();          if(how==0){          scaleWidth = ((float) width) / bmpwidth;           scaleHeight = ((float) height) / bmpheight;           }else{            scaleWidth=Math.min(width,height)/bmpwidth;            scaleHeight=Math.min(width, height)/bmpheight;    }  private Bitmap getImageFromAssetFile(String fileName,int how){        Bitmap image = null ;          try {            AssetManager am = game.getAssets();            InputStream is = am.open(fileName);            image = BitmapFactory.decodeStream(is);             is.close();              }catch (Exception e){   };        return zoomImage(image,how);    }   public Bitmap zoomImage(Bitmap bgimage,int how) {         int bmpwidth = bgimage.getWidth();         int bmpheight = bgimage.getHeight();         float scaleWidth=0;        float scaleHeight=0;         Matrix matrix = new Matrix();         if(how==0){          scaleWidth = ((float) width) / bmpwidth;          scaleHeight = ((float) height) / bmpheight;          }else{           scaleWidth=Math.min(width,height)/bmpwidth;           scaleHeight=Math.min(width, height)/bmpheight;  }  
  相关解决方案