posted 11 years ago
Hi,
I am trying to load a png image file from a byte array(from stream) and got this error :
01-09 12:01:24.664: E/AndroidRuntime(14031): java.lang.OutOfMemoryError
01-09 12:01:24.664: E/AndroidRuntime(14031): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
01-09 12:01:24.664: E/AndroidRuntime(14031): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
My code is :
ByteArrayOutputStream out = new ByteArrayOutputStream(ByteWritten);
byte[] actual_bytes = new byte[1024];
long count = 1024;
long off = 0;
while((actual_bytes = solstream.readWithSeek(off,count))!=null) // this is virtual space stream where the image file is stored
{
off=off+actual_bytes.length;
out.write(actual_bytes,0,actual_bytes.length);
}
out.flush();
out.close();
byte[] final_ba = out.toByteArray();
bitmap = BitmapFactory.decodeByteArray(final_ba,0,final_ba.length);
image = (ImageView) findViewById(R.id.rtimageView);
image.setImageBitmap(bitmap);
Thanks in advance.
Swapna.