cats-oss / android-gpuimage

Android filters based on OpenGL (idea from GPUImage for iOS)
9k stars 2.27k forks source link

Use GPUImageFilterGroup when image is center_ Inside mode is invalid to change the background color in GPUImageView #531

Open xuzhiyong017 opened 3 years ago

xuzhiyong017 commented 3 years ago

What does this change?

Added the method of setting the background color, and adjust the order of the filter drawing

What is the value of this and can you measure success?

It can change the background color when gpuimageview is invalid,for example the ImageActivity

Screenshots

微信图片_20210722143423

        gpuImage.setScaleType(GPUImage.ScaleType.CENTER_INSIDE)
        gpuImage.filter = GPUImageFilterGroup(listOf(GPUImageBrightnessFilter(),
            GPUImageSaturationFilter(),
            GPUImageWhiteBalanceFilter(),
            GPUImageSharpenFilter())).apply {
            setBackgroundColor(0.27f, 0.27f, 0.27f)
        }
        gpuImage.setBackgroundColor(1f,1f,1f)
        gpuImage.setImage(Uri.parse("file:///android_asset/image.png"))
longdt57 commented 1 year ago

This fix is great. It saves lots of time.