universal image loader - Top crop with ImageLoader - Android -
i'm loading images urls imageview -
imageloader.getinstance().displayimage(url, imageview, display-options)
now crop image center top. tried using https://gist.github.com/arriolac/3843346 think expects image via drawable , want use imageloader set image.
can me understand if can use https://code.google.com/archive/p/android-query/ (android query) in conjunction imageloader?
is there way handle cropping in android (apart centercrop) natively?
replace imageview profileimageview , enjoy view :)
public class profileimageview extends imageview { private bitmap bm; public profileimageview(context context, attributeset attrs) { super(context, attrs); bm = null; } @override protected void onlayout(boolean changed, int left, int top, int right, int bottom) { super.onlayout(changed, left, top, right, bottom); if (bm != null) { setimagebitmap(bm); bm = null; } } @override public void setimagebitmap(bitmap bm) { int viewwidth = getwidth(); int viewheight = getheight(); if (viewwidth == 0 || viewheight == 0) { this.bm = bm; return; } setscaletype(scaletype.matrix); matrix m = getimagematrix(); m.reset(); int min = math.min(bm.getwidth(), bm.getheight()); int cut; if (bm.getwidth() > viewwidth && bm.getwidth() > bm.getheight()) { cut = math.round((bm.getwidth() - viewwidth) / 2.f); } else { cut = 0; } rectf drawablerect = new rectf(cut, 0, min - cut, min); rectf viewrect = new rectf(0, 0, viewwidth, viewheight); m.setrecttorect(drawablerect, viewrect, matrix.scaletofit.start); setimagematrix(m); super.setimagebitmap(bm); }
}
Comments
Post a Comment