BitmapFactory.Options學習筆記

來源:互聯網
上載者:User

標籤:

1,android解析度為240 × 320,densityDpi為120;

2,android解析度為320 x 480,densityDpi為160;

3,android解析度為480 x 800或者480 x 854,densityDpi為240;

4,android解析度為720 x 1280,densityDpi為320;

5,android解析度為1080 x 1920,densityDpi為480;


6,DisplayMetrics.DENSITY_DEFAULT的值在不同解析度不同密度的手機上都是160;

7,用BitmapFactory解析一個bitmap,得到一個Bitmap的執行個體,這個執行個體的getDensity()方法返回一個螢幕密度值,這個密度值是基於解析度而不同的,它的值可以對照前5條。

8,用BitmapFactory解析一個bitmap,不設定BitmapFactory.Options的值,分析得到的這個Bitmap執行個體,這個Bitmap執行個體的getWidth()和getHeight()方法返回的是圖片的原生解析度長寬(即,getWidth()返回圖片的原始寬,getHeight()返回圖片的原始高)。

9,用BitmapFactory解析一個bitmap,用下面的代碼設定BitmapFactory.Options的值,分析得到的這個Bitmap執行個體,得到這樣結論:

        opts.inTargetDensity = getResources().getDisplayMetrics().densityDpi;        opts.inDensity = DisplayMetrics.DENSITY_DEFAULT;

這個Bitmap執行個體的getWidth()方法返回的值是圖片原始寬的opts.inTargetDensity / opts.inDensity倍,getHeight()方法返回的值是圖片原始高的opts.inTargetDensity / opts.inDensity倍,而getDensity()方法返回的值和上述第7條一致。



BitmapFactory.Options學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.