Getting half image when convert bitmap to base64
<p>I want to upload image to server which is accept images in base64 encored format. I use this code to encode bitmap, But it encode only half of the image and server receive only half of the image part.</p>

<p>This is my code.</p>

<pre><code>ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            photo.compress(Bitmap.CompressFormat.PNG, 10, byteArrayOutputStream);
            byte[] byteArray = byteArrayOutputStream .toByteArray();

            String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
// Send to server(encoded)
</code></pre>

<p>and when I try to encode image from gallery it pop up a error and crashes the app, with error.</p>

<p>java.lang.OutOfMemoryError: Failed to allocate a 15521174 byte allocation with 13777320 free bytes and 13MB until OOM</p>

<p>I want to encode the full image, any help?</p>