user420574
user420574

Reputation: 1457

Bitmap to String using Base64. How can fix it?

The Base64.encode doesn't want to take the argument "image", and I don't know how to figure out. I've never used Base64 before.

Bitmap bm = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri));
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
                    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object   
                    byte[] image = baos.toByteArray();

                    String encodedImage = Base64.encode(image);

Edit: I use an external package of Base64 http://iharder.sourceforge.net/current/java/base64/

Upvotes: 0

Views: 5954

Answers (1)

Drew
Drew

Reputation: 2299

Base64 encode takes at least two arguments. Perhaps try Base64.encode(image, Base64.DEFAULT)

Upvotes: 2

Related Questions