Converting a bitmap to a byte array WITHOUT Bitmap.CompressFormat

Is there a way to convert a bitmap to a byte array without the Bitmap.CompressFormat class in Android? if not, then how? if possible let me know how thanx

+4
source share
1 answer

Something like that?

//b is the Bitmap //calculate how many bytes our image consists of. int bytes = b.getByteCount(); //or we can calculate bytes this way. Use a different value than 4 if you don't use 32bit images. //int bytes = b.getWidth()*b.getHeight()*4; ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer b.copyPixelsToBuffer(buffer); //Move the byte data to the buffer byte[] array = buffer.array(); //Get the underlying array containing the data. 

WITH; fooobar.com/questions/86180 / ...

+1
source

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


All Articles