在毕加索加载实际图像之前模糊缩略图 [英] Blur thumbnail image before loading actual image in picasso

查看:137
本文介绍了在毕加索加载实际图像之前模糊缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用毕加索从URL显示图像,我在加载实际图像之前首先显示缩略图,我想模糊缩略图,我在毕加索中如何实现?

i am using picasso to display the image from URL, i am displaying thumbnail image first before loading actual image, i want to blur that thumbnail image , how i can achieve in picasso ?

这是我的源代码

pb.setVisibility(View.GONE);
        Picasso.with(getApplicationContext())
                .load(thumbUrl) // thumbnail url goes here
                //.placeholder(R.drawable.progress_animation)
                .resize(width, width)
                .transform(new BlurTransformation(getApplicationContext(), 25, 1))
                .into(imageview, new Callback()
                {
                    @Override
                    public void onSuccess()
                    {
                        pb.setVisibility(View.GONE);
                        Log.e(TAG,"OnSuccess");
                        Picasso.with(getApplicationContext())
                                .load(url) // image url goes here
                                .resize(width, width)
                                .placeholder(imageview.getDrawable())
                                .into(imageview);
                        iv_reDownload.setVisibility(View.GONE);
                    }

                    @Override
                    public void onError()
                    {
                        pb.setVisibility(View.GONE);
                        Log.e(TAG,"OnError");
                        Picasso.with(getApplicationContext())
                                .load(url) // image url goes here
                                .resize(width, width)
                                .placeholder(imageview.getDrawable())
                                .into(imageview);
                        iv_reDownload.setVisibility(View.VISIBLE);
                    }
                });


推荐答案

最后,我借助此解决了我的问题图书馆命名为picasso-transformations,我在项目中添加了以下依赖项

finally, i solved my problem with the help of this Library named as picasso-transformations , i added the below dependencies in my project

compile 'jp.wasabeef:picasso-transformations:2.2.1'

不仅支持 Picasso ,还支持 Glide Fresco
我在毕加索里面打了 BlurTransformation 课。

not only it support Picasso but also it support Glide or Fresco too and i called the BlurTransformation class inside picasso.

这里是完整的例子

pb.setVisibility(View.GONE);
        Picasso.with(getApplicationContext())
                .load(thumbUrl) // thumbnail url goes here
                //.placeholder(R.drawable.progress_animation)
                .resize(width, width)
                .transform(new BlurTransformation(getApplicationContext(), 25, 1))
                .into(imageview, new Callback()
                {
                    @Override
                    public void onSuccess()
                    {
                        pb.setVisibility(View.GONE);
                        Log.e(TAG,"OnSuccess");
                        Picasso.with(getApplicationContext())
                                .load(url) // image url goes here
                                .resize(width, width)
                                .placeholder(imageview.getDrawable())
                                .into(imageview);
                        iv_reDownload.setVisibility(View.GONE);
                    }

                    @Override
                    public void onError()
                    {
                        pb.setVisibility(View.GONE);
                        Log.e(TAG,"OnError");
                        Picasso.with(getApplicationContext())
                                .load(url) // image url goes here
                                .resize(width, width)
                                .placeholder(imageview.getDrawable())
                                .into(imageview);
                        iv_reDownload.setVisibility(View.VISIBLE);
                    }
                });

这篇关于在毕加索加载实际图像之前模糊缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆