[英]GPUImageView with Glide
I am trying to implement an Android image filter library called GPUImageView .我正在尝试实现一个名为GPUImageView的 Android 图像过滤器库。
I have tried to use it like in the below code:我试图像下面的代码一样使用它:
public static GPUImageView img_bg;
img_bg = (GPUImageView) findViewById(R.id.img_bg);
categoryAdapter1.setOnClickLIstner(new OnClickLIstner() {
@Override
public void onClick(View v, Image image, int pos) {
Glide.with(NameArt.this)
.load(image.getDrawableId())
.centerCrop()
.dontAnimate()
.into(img_bg);
img_bg.setVisibility(View.VISIBLE);
}
});
But I am getting an error:但我收到一个错误:
cannot resolve method 'into' (
jp.co.cyberagent.android.gpuimage.GPUImageView
)无法解析方法“进入”(jp.co.cyberagent.android.gpuimage.GPUImageView
)
Does anyone know how to resolve this?有谁知道如何解决这个问题? Thanks谢谢
GPUImageView
is not a subclass of ImageView. GPUImageView
不是 ImageView 的子类。 Write a custom subclass of com.bumptech.glide.request.target.Target
that overrides onResourceReady
to call GPUImageView::setImage(Bitmap)
编写com.bumptech.glide.request.target.Target
的自定义子类,覆盖onResourceReady
以调用GPUImageView::setImage(Bitmap)
This Will help you to solve that problem.这将帮助您解决该问题。
Glide.with(getApplicationContext()).load( IMAGE )
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
BITMAP= resource;
}
});
and compile version of glide below.并编译下面的glide版本。
compile 'com.github.bumptech.glide:glide:3.7.0'
As previously stated, GPUImageView is not a subclass of ImageView.如前所述,GPUImageView 不是 ImageView 的子类。 with Glide 4.9.0 and GPUImage 2.0.4,使用 Glide 4.9.0 和 GPUImage 2.0.4,
add on your layout添加您的布局
<jp.co.cyberagent.android.gpuimage.GPUImageView
android:id="@+id/picture_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:gpuimage_show_loading="false"
app:gpuimage_surface_type="texture_view"
/>
and in your code:并在您的代码中:
val pp = findViewById<GPUImageView>(R.id.picture_player)
Glide.with(this).asBitmap()
.load(uri)
.into(object : CustomViewTarget<GPUImageView, Bitmap>(pp) {
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
pp.setImage(resource)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onResourceCleared(placeholder: Drawable?) {
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.