GpuImage does not render properly

252 views Asked by At

Currently I am working on an Android App with GpuImage Library. My goal is to apply filters on images via GpuImage.

GpuImage gpuImage = new GpuImage(this);
gpuImage.setBitmap(imageBitmap) // bitmap of the image that I want to apply effect on
gpuImageView = findViewById(R.id.gpuimageview); //it is ImageView
gpuImage.setFilter(new GPUImageSobelEdgeDetection());
gpuImageView.setBitmap(gpuImage.getBitmapWithFilterApplied());

This is how I basically apply effect on image via GpuImage and get filter applied bitmap. But when I quickly apply effects to the image in sequence with different GpuImage filters like shown below:

ArrayList filtersList = new ArrayList<GpuImageFilter>()
...
//Fill the array with various GpuImage filters
...
GpuImage gpuImage = new GpuImage(this);
gpuImage.setBitmap(imageBitmap) // bitmap of the image that I want to apply effect on
button = findViewById(R.id.button);
gpuImageView = findViewById(R.id.gpuimageview); //it is ImageView

//button that changes filter at every click
button.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
    if(filtersList.size() > 0){
        gpuImage.setFilter(filtersList.get(filtersList.size()-1));
        filtersList.remove(filtersList.size()-1);
        gpuImageView.setBitmap(gpuImage.getBitmapWithFilterApplied());
    }

});

When I click on the button repeatedly and quickly, I get a bitmap with just filled with a color like gray. Is there any way to prevent this issue? Or how can I be sure that is GpuImage is done with the rendering before I apply another effect?

0

There are 0 answers