1

I am using GPUImageView component from android-gpuimage Library for displaying Images (with filtered applied on them) in my ListView.

The Images are being loaded perfectly with filters for the First time in my ListView but when i scroll down the ListView, all the Scrolled Cells are displayed Blank.

Here is the code of the getView(...) method of my custom BaseAdapter :

@Override
public View getView(int position, View convert_view, ViewGroup arg2) {
    // TODO Auto-generated method stub

    if(convert_view == null)
    {
        if(inflater == null)
            inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        convert_view = inflater.inflate( R.layout.filter_item , null);

    }

    TextView thumb_file_name_tv = (TextView) convert_view.findViewById(R.id.filter_item_thumb_tv);

    GPUImageView thumb_giv = (GPUImageView) convert_view.findViewById(R.id.filter_item_thumb_giv);

    Log.d(TAG, "Image Uri = "+imageUri);

    thumb_file_name_tv.setText(""+filterNames.get(position).toString().trim());

    thumb_giv.setFilter(new GPUImageSepiaFilter());

    thumb_giv.setImage(imageUri); // this loads image on the current thread, should be run in a thread

    thumb_giv.requestRender();

    return convert_view;

}

Please tell me what i am doing wrong here ?
Any help is highly appreciated.

Salman Khakwani
  • 6,684
  • 7
  • 33
  • 58

2 Answers2

1

With the new version of GPUImage the deleteImage () method does not exist, I do the following and it worked perfectly.

@BindView(R.id.editor)
GPUImageView mEditor;

Inside the OnClick that changes the bitmap of the image, do the following:

mEditor.getGPUImage().deleteImage();
mEditor.setImage(newBitmap);

In this way I delete the previous Bitmap and I can apply the new Bitmap without any problem.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
GlobalSoft
  • 11
  • 1
0

It has been a while since I used that library, but from what I remember, if you change the image in the view, you need to call deleteImage() before settings the new image.
Try calling that method before calling setImage() You might need to check if the view has an image present before you can call deleteImage() or it might throw an error.

Edit :
Add the following methods to the GPUImageView.java class of the android-gpuImage library :

public void deleteImage() 
{
 mGPUImage.deleteImage(); 
}
Salman Khakwani
  • 6,684
  • 7
  • 33
  • 58
KennyC
  • 593
  • 4
  • 12
  • Thanks for your reply, i am trying this solution now. – Salman Khakwani Mar 25 '14 at 11:39
  • There is no Method such as `deleteImage()` in the `GPUImageView`, but there is a similar method that is `deleteDrawingCache()` and after using it, the `GPUImageView` is always rendering Blank. – Salman Khakwani Mar 25 '14 at 13:54
  • 1
    Sorry, I added that one myself and forgot to mention that. In the GPUImageView class, add the following method: public void deleteImage() { mGPUImage.deleteImage(); } – KennyC Mar 25 '14 at 13:55