patrickfav / Dali

Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.
https://favr.dev/opensource/dali
Apache License 2.0
1.05k stars 89 forks source link

Color distorted for RGB_565 bitmaps with renderscript blur algorithms #19

Open diegor2 opened 4 years ago

diegor2 commented 4 years ago

I need to copy to a new bitmap using ARGB_8888 config to get the correct image, otherwise the colors get really trippy

diegor2 commented 4 years ago
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        GlobalScope.launch(Dispatchers.IO) {
            val url = "https://upload.wikimedia.org/wikipedia/commons/a/ad/Gretag-Macbeth_ColorChecker.jpg"
            val stream = URL(url).openStream()
            val bitmap = BitmapFactory.decodeStream(stream)
                .copy(Bitmap.Config.RGB_565, false)

            Dali.create(this@MainActivity)
                .load(bitmap)
                .skipCache()
                .blurRadius(12)
                .into(image);
        }
    }
}

Screenshot_20200612-232809

patrickfav commented 4 years ago

Hmm, if you use the default config, this lib just uses the built-in renderscript blur algo. I think I never tested with 565, but I guess there is no easy fix for this - aka I believe this is a Renderscript bug.

patrickfav commented 4 years ago

Relates to #20