av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Android圖片大小調(diào)整動態(tài)實現(xiàn)方法

Android操作系統(tǒng)中對于圖片的操作我們在以前的文章中也有所介紹。不過對于圖片的大小調(diào)整往往都局限于固定的調(diào)整。如何才能滿足動態(tài)大小調(diào)整呢?我們在這里就為大家詳細介紹有關(guān)Android圖片大小調(diào)整的動態(tài)實現(xiàn)方法。

涿鹿ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

昨天,動態(tài)獲取圖片資源獲取的很爽啊,后來,換了一張png,128*128的,Run as android application,天哪,居然覆蓋了我大半個屏幕,都不留一點情面給我展示了。。。??磥?,必須要找個方法讓圖片自適應(yīng)大小,于是修改了一下獲取圖片的代碼,讓圖片能自適應(yīng)。

一下就是Android圖片大小調(diào)整的相關(guān)代碼示例:

 
 
 
  1. view plaincopy to clipboardprint?  
  2. private Bitmap getImageFromAssetFile(String fileName,int how){   
  3. Bitmap image = null ;   
  4. try {   
  5. AssetManager am = game.getAssets();   
  6. InputStream is = am.open(fileName);   
  7. image = BitmapFactory.decodeStream(is);   
  8. is.close();   
  9. }catch (Exception e){   
  10. }   
  11. return zoomImage(image,how);   
  12. }   
  13. public Bitmap zoomImage(Bitmap bgimage,int how) {   
  14. int bmpwidth = bgimage.getWidth();   
  15. int bmpheight = bgimage.getHeight();   
  16. float scaleWidth=0;   
  17. float scaleHeight=0;   
  18. Matrix matrix = new Matrix();   
  19. if(how==0){   
  20. scaleWidth = ((float) width) / bmpwidth;   
  21. scaleHeight = ((float) height) / bmpheight;   
  22. }else{   
  23. scaleWidth=Math.min(width,height)/bmpwidth;   
  24. scaleHeight=Math.min(width, height)/bmpheight;   
  25. }   
  26. private Bitmap getImageFromAssetFile(String fileName,int how){   
  27. Bitmap image = null ;   
  28. try {   
  29. AssetManager am = game.getAssets();   
  30. InputStream is = am.open(fileName);   
  31. image = BitmapFactory.decodeStream(is);   
  32. is.close();   
  33. }catch (Exception e){   
  34. }   
  35. return zoomImage(image,how);   
  36. }   
  37. public Bitmap zoomImage(Bitmap bgimage,int how) {  
  38. int bmpwidth = bgimage.getWidth();  
  39. int bmpheight = bgimage.getHeight();  
  40. float scaleWidth=0;  
  41. float scaleHeight=0;  
  42. Matrix matrix = new Matrix();  
  43. if(how==0){  
  44. scaleWidth = ((float) width) / bmpwidth;  
  45. scaleHeight = ((float) height) / bmpheight;  
  46. }else{  
  47. scaleWidth=Math.min(width,height)/bmpwidth;  
  48. scaleHeight=Math.min(width, height)/bmpheight;  
  49. }  

其中,scaleWidth和scaleHeight是欲縮放后的大小,這里加個參數(shù)how是防止有不需要縮放的情況~

Android圖片大小調(diào)整的操作方法就為大家介紹到這里。

【編輯推薦】

  1. Android界面互調(diào)具體應(yīng)用方式解析 
  2. Android智能指針使用方法介紹 
  3. Android查詢聯(lián)系人信息正確操作方法 
  4. Android命令行啟動程序正確使用技巧解析 
  5. 全方位解讀Android多媒體框架源碼 

當(dāng)前文章:Android圖片大小調(diào)整動態(tài)實現(xiàn)方法
鏈接URL:http://uogjgqi.cn/article/ccegshe.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流