convert bitmap to array of bytes [closed]

0

I try to convert a bitmap file in android, to an array of bytes and then pass it to a web service asmx, and since it is saved in a sql database, but I get compatibility error, would anyone know how I can do it?

    
asked by juanjo 12.04.2018 в 20:58
source

1 answer

1

The best way to convert a bitmap to an array of bytes is as follows:

Bitmap bmp = intent.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
bmp.recycle();

Try to see if this way you have no problems.

    
answered by 13.04.2018 в 13:12