I am trying to implement an Android image filter library called GPUImageView .
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
)
Does anyone know how to resolve this? Thanks
GPUImageView
is not a subclass of ImageView. Write a custom subclass of com.bumptech.glide.request.target.Target
that overrides onResourceReady
to call 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.
compile 'com.github.bumptech.glide:glide:3.7.0'
As previously stated, GPUImageView is not a subclass of ImageView. with Glide 4.9.0 and 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.
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.