ImageLoader.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:Retrofit2SampleApp 作者:
@Override
public void loadImage(String url,final ImageView imageView) {

    Picasso.with(imageView.getContext()).load(url).transform(new Transformation() {
        @Override
        public Bitmap transform(Bitmap source) {
            Bitmap combinedBitmap;
            combinedBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight() / 3 + source.getHeight(), source.getConfig());

            Canvas combinedCanvas = new Canvas(combinedBitmap);
            combinedCanvas.drawBitmap(source, 0f, 0f, null);

            Matrix matrix = new Matrix();
            matrix.postRotate(180);
            matrix.preScale(-1, 1);
            matrix.postTranslate(0, source.getHeight() * 2);

            BlurTransformation blurTransformation = new BlurTransformation(imageView.getContext(), 15, 1);
            Bitmap bottom = blurTransformation.transform(source);

            combinedCanvas.setMatrix(matrix);
            combinedCanvas.drawBitmap(bottom, 0f, 0f, null);
            return combinedBitmap;
        }

        @Override
        public String key() {
            return ImageLoader.class.getName() + ".Transformation";
        }
    }).error(android.R.drawable.sym_contact_card).placeholder(android.R.drawable.sym_contact_card).
            into(imageView);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号