Change bit depth from bitmap

So, I have an image with a depth of 32 bits, but when I make it in the blob for my SQLite database and read it again with the following code, it has only 24-bit depth (the quality is lower, I want it to be that same quality). How do I get 32-bit depth?

DatabaseHandler db = new DatabaseHandler(camera.this); List<Database> contacts = db.getAllContacts(); for (Database contact : contacts) { BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options(); bmpFactoryOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; //bmpFactoryOptions.inScaled = false; bmpFactoryOptions.outHeight = 240; bmpFactoryOptions.outWidth = 320; // decodes the blob back into a bitmap byte[] blob = contact.getMP(); ByteArrayInputStream inputStream = new ByteArrayInputStream(blob); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); Bitmap scalen = Bitmap.createScaledBitmap(bitmap, 320, 240, false); 

Coding source

 Bitmap image15 = BitmapFactory.decodeResource(getResources(),R.drawable.wolverineklein); // convert bitmap to byte ByteArrayOutputStream stream = new ByteArrayOutputStream(); image15.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte imageInByte1[] = stream.toByteArray(); 

Left are the properties of the input image (32 bit depth) and right is the output image (24 bit depth)

+4
source share
1 answer

There is no such thing as 24 bit depth on Android. The bitmap can be either 8 bits (only translucency of the ALPHA 8 format, or zero configuration for scaled formats), 16 bits (565 RGB format without transparency or 4444 RGBA format with transparency) or 32 bits (8888 RGBA format with transparency).

Update: this means that you do not have an alpha channel. Colors are encoded using 24 bits in both cases.

+3
source

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


All Articles