首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

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

2012-09-19 
Android图片大小调整动态实现主要代码view plaincopy to clipboardprint?private Bitmap getImageFromAsse

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;  }  

热点排行