When dealing with some bitmaps in Android I noticed that the white used in views is not always the same white rendered on bitmaps. Consider this screenshot.
The background white is from a view with white background color.
The foreground "white" is from a white bitmap decoded from the SD card, displayed in an ImageView. This bitmap is decoded using RGB_565
as follows:
BitmapFactory.Options resample = new BitmapFactory.Options();
resample.inPreferredConfig = Config.RGB_565;
resample.inSampleSize = sampleSize;
return BitmapFactory.decodeFile(filePath, resample);
For reference, here's the bitmap.
Why is this and how can it be fixed?
Some consider white to be a color, because white light comprises all hues on the visible light spectrum. And many do consider black to be a color, because you combine other pigments to create it on paper. But in a technical sense, black and white are not colors, they're shades. They augment colors.
In physics, a color is visible light with a specific wavelength. Black and white are not colors because they do not have specific wavelengths. Instead, white light contains all wavelengths of visible light. Black, on the other hand, is the absence of visible light.
Colors like white and pink are not present in the spectrum because they are the result of our eyes' mixing wavelengths of light. White is what we see when all wavelengths of light are reflected off an object, while pink is a mix of the red and violet wavelengths.
Colors often considered "shades of white" include cream, eggshell, ivory, Navajo white, and vanilla. Even the lighting of a room, however, can cause a pure white to be perceived as off-white. Off-white colors were pervasively paired with beiges in the 1930s, and especially popular again from roughly 1955 to 1975.
I have the same issue and after some experiments I noticed that commenting <uses-sdk>
solves the problem. Any value for android:minSdkVersion
above 3 will make this effect appear (removing <uses-sdk>
tag effectively changes minSdkVersion
to 1.
Try setting getWindow().setFormat(PixelFormat.RGB_565)
in your onCreate.
The default format seems to change based on SDK version and device type, so just force it to stay at RGB_565
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With