小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

圖片加載得工具類

 火柴個(gè)人資料館 2017-05-02
自己寫的項(xiàng)目 對(duì)圖片加載要求不高 所以在加載得時(shí)候用了 幾個(gè)常見得加載工具
glide 
Picasso
image-loader
有點(diǎn)蛋疼 其實(shí)都沒有什么太大得差別 只是完成異步加載就行了  
導(dǎo)入得 
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
imagerloder 得包下的是本地 想用得可以自己百度導(dǎo)入地址
用imagerloder 的在 
 
 每次都得先instance 有點(diǎn)麻煩
用Glide就方便多了 有小問題事不能加載bitmap圖片 還得轉(zhuǎn)成成btye【】
還有圖像顯示方向 在三星手機(jī)上拍照會(huì)自動(dòng)旋轉(zhuǎn)90度
所以我又加了方向調(diào)整 但是問題是這個(gè)0f 是指照片本來(lái)就是正常方向?yàn)?f
在三星上會(huì)把拍出來(lái)的照片左旋轉(zhuǎn)90度作為0f 這個(gè)就尷尬了 這個(gè)方法就沒用了 只能用過在加載得控件獲取方向調(diào)整了 好麻煩
new RotateTransformation(getActivity(), 0f)

Glide.with(getActivity().getApplicationContext()).load(HttpUrlUtil.URL_PRE + uHeadImage)//圖片得加載地址
.transform(new RotateTransformation(getActivity(), 0f))
.error(R.mipmap.load_img_error)//加載錯(cuò)誤時(shí)顯示得圖片
.into(userImgView);//圖片加載得控件id
Glide還有加載圖片時(shí)過度圖片得設(shè)置方法 對(duì)異步加載圖片來(lái)說完全夠用了
有需求得可以研究下Glide得文檔 隨便寫寫 以后查找方便

//簡(jiǎn)單得查詢圖像方向 進(jìn)行調(diào)整 0f不旋轉(zhuǎn) 90f旋轉(zhuǎn)90度
public class RotateTransformation extends BitmapTransformation {
private float rotateRotationAngle = 0f;

public RotateTransformation(Context context, float rotateRotationAngle) {
super(context);
this.rotateRotationAngle = rotateRotationAngle;
}

@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
Matrix matrix = new Matrix();
matrix.postRotate(rotateRotationAngle);
return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true);
}

@Override
public String getId() {
return "rotate" + rotateRotationAngle;
}
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多