0
Bitmap foto = b.getBitmap();

byte[] bytes = null;
ByteArrayOutputStream ba = new ByteArrayOutputStream();
foto.compress(Bitmap.CompressFormat.JPEG, 100, ba);
foto.recycle();
foto = null;

bytes = ba.toByteArray();

String bBytes = Arrays.toString(bytes);

I'd like this method to return a String of the Byte values. For example, it would be : "12,23,34 ....".

3
  • So you expect folks to first translate your question? Commented Mar 13, 2014 at 16:32
  • I've tried to fix what I've understood in his question. Commented Mar 13, 2014 at 16:35
  • Which method do you mean by this method?! Commented Mar 13, 2014 at 16:40

1 Answer 1

1

Here is how you can do it.

import java.util.Arrays;

public class Test {

    public static void main(String[] args) {
        byte[] bytes = {1,2,3,12};
        String bBytes = Arrays.toString(bytes);
        bBytes = bBytes.replaceAll(" ", "");
        bBytes = bBytes.replaceAll("\\[", "");
        bBytes = bBytes.replaceAll("\\]", "");
        System.out.println(bBytes);     
    }

}
Sign up to request clarification or add additional context in comments.

3 Comments

when small bitmap, works perfect, but when and large bitmap, this conversion takes too long, already thought about doing that with NDK, maybe the performace is excellent. The problem is this line: String bBytes = Arrays.toString(bytes);
First time you mention about performance issues. Post another question, I would suggest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.