Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InDither deprecated in android N

Tags:

android

bitmap

As the title implies the inDither field in BitmapFactory.Options is now deprecated. Android doc says "This field was deprecated in API level 24. As of N, this is ignored." Does anyone know why it has been deprecated and is there a alternative for this?

like image 882
Naveen Dissanayake Avatar asked Feb 09 '17 11:02

Naveen Dissanayake


People also ask

What is deprecation in Android?

What is deprecation ? In Android deprecation usually means “ We will continue to support this, but we think there are better solutions ”. Most of the time features are deprecated rather than immediately removed, to provide backward compatibility, and to give programmers time to bring affected code into compliance with the new standard.

What happens when a feature is deprecated?

Most of the time features are deprecated rather than immediately removed, to provide backward compatibility, and to give programmers time to bring affected code into compliance with the new standard.

Is it worth it to research why a method is deprecated?

By researching why a method is deprecated I often learn interesting things about SDK and different ways of doing same thing. There is often a good reason behind deprecation which leads to better understanding of the Android SDK. So from a learning/growing perspective, it is also a worthwhile effort.

What are the disadvantages of using deprecated methods in Java?

The main disadvantage is that the API might not be available in future versions, which will increase the cost of updating your application. If the deprecated method is easy to replace, use the replacement. If it isn’t, it’s up to you to decide whether developing the “future-proof” way is worth the additional effort.


1 Answers

seems it is too late to answer...

if you use canvas.drawBitmap, you may try:

Paint().apply {
            isDither = false
            isFilterBitmap = false
            isAntiAlias = false
        }

and for ImageView, setLayerPaint seems not suitable, you may create a BitmapDrawable like:

BitmapDrawable(resources, bitmap).apply {
            setAntiAlias(false)
            isFilterBitmap = false
        }
  1. Android: Disabling anti-aliasing for pixel art (blog)

  2. Disable anti-aliasing on Android Imageview (StackOverflow question)

like image 187
fung Avatar answered Oct 23 '22 22:10

fung