我就廢話不多說了,大家還是直接看代碼吧~

//Uri.parse("file://"+result.getImage().getCompressPath()))
String path=uri.getPath();
Log.e("圖片路徑",path+"");
SpannableString spannableString=new SpannableString(path);
//方法一:通過uri把圖片轉化為bitmap的方法
Bitmap bitmap= BitmapFactory.decodeFile(path);
int height= bitmap.getHeight();
int width= bitmap.getWidth();
Log.e("通過bitmap獲取到的圖片大小","width:"+width+"height"+height);
//方法二:使用Options類來獲取
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;//這個參數(shù)設置為true才有效,
Bitmap bmp = BitmapFactory.decodeFile(path, options);//這里的bitmap是個空
if(bmp==null){
Log.e("通過options獲取到的bitmap為空","===");
}
int outHeight=options.outHeight;
int outWidth= options.outWidth;
Log.e("通過Options獲取到的圖片大小","width:"+outWidth+"height"+outHeight);
網(wǎng)站名稱:android獲取圖片尺寸的兩種方式及bitmap的縮放操作-創(chuàng)新互聯(lián)
本文URL:http://chinadenli.net/article40/hpdho.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、手機網(wǎng)站建設、網(wǎng)站制作、域名注冊、微信公眾號、關鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容