I'm trying to load a PNG into a Bitmap object using BitmapFactory like this:
BitmapFactory.decodeResource(resources, R.drawable.tile_18_23);
The raw values of the pixels will be used in a GL shader program and need to be exact (or at least as close as floats every get) but what I'm getting is clipped for low values (anything lower than RGB 20 or so is translated to zero for any color channel) and some sort of color-space mapping appears to be happening that I haven't been able to reason about. The values are off by 2x or more.
I've tried tons of configurations of BitmapFactory.Options but none of them seem to produce output consistent with raw input. In worst-case I'd be ok with re-mapping the colors but can't figure out the logic it's using and neither options.inPreferredColorSpace or options.outColorSpace appear to have much impact. Based on other answers, here's my best attempt at options that still doesn't work:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bm = BitmapFactory.decodeResource(resources, R.drawable.tile_18_23, options);
Tried putting the image in both assets and drawable-nodpi without any change.
If I read the PNG using Golang, all the channels have exactly the values I'd expect in the PNG so I don't think the problem is in creation of the PNG.