I am facing one real issue. I need to convert image into byte array format, so that I can upload the byte array into web server. I have tried a lot however its not working. I am also getting negative values for byte array. I am not sure what i am doing wrong to take byte values in array.
Below is my code. Please help me what i am doing wrong?
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.home_menu_icon);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] data = bos.toByteArray();
bmp.compress(Bitmap.CompressFormat.PNG, 100, bos);Otherwise the code code seems to be OK.The fact that primitives are signed in Java is irrelevant - A byte is merely 8 bits and whether you interpret that as a signed range or not is up to you. There is no magic flag to say "this is signed" or "this is unsigned".