Android bitmap issues

In my application, the bitmap is drawn as if the color were lower. If I upload a background image using the gallery app, it loads just fine and doesn't look very low. The code I use to upload and draw images is simple:

//Code for initializing the Bitmap Bitmap bitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.none), (int) (canvas.getWidth() * compression), (int) (canvas.getHeight() * compression), true); //... //Code for drawing this Bitmap canvas.drawBitmap(bitmap, null, new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), null); 

If nothing in the code tells you what is wrong, I made an image comparing the image that actually looks on a computer or other image viewer and how it looks in the application. Top image is the app on the phone, bottom image is what the background image actually looks like. Notice the lines on the top image. What is up with that?

+4
source share
1 answer
Question

somewhat similar to Poor image quality after resizing / scaling a bitmap

try disabling scaling, resizing in the bitmap off-screen, and make sure the bitmap is 32 bits (ARGB888):

 Options options = new BitmapFactory.Options(); options.inScaled = false; options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap source = BitmapFactory.decodeResource(a.getResources(), path, options); 

Another good and complete answer about image scaling / processing can be found in Quality problems when resizing images at runtime.

+5
source

Source: https://habr.com/ru/post/1412201/


All Articles