Dali icon indicating copy to clipboard operation
Dali copied to clipboard

Color distorted for RGB_565 bitmaps with renderscript blur algorithms

Open diegor2 opened this issue 4 years ago • 3 comments

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

diegor2 avatar Jun 12 '20 21:06 diegor2

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

diegor2 avatar Jun 12 '20 23:06 diegor2

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 avatar Jun 13 '20 20:06 patrickfav

Relates to #20

patrickfav avatar Jun 13 '20 20:06 patrickfav