Hi Jon,

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jonathan Pryor
Sent: dimecres, 30 / novembre / 2011 15:40
To: Discussions related to Mono for Android
Subject: Re: [mono-android] Trouble with Android.Graphics
>
>It's a bug in your code. When you write to a stream, the Position of the
stream is at end-of-stream:
>
>>        System.IO.MemoryStream stream = new System.IO.MemoryStream();
>>        if (bmp.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 100,
stream))
>>        {
>>          Android.Graphics.Bitmap b =
Android.Graphics.BitmapFactory.DecodeStream(stream);
>
>Notice that you don't rewind the stream, so the stream you're passing to
Java is at EOF, and thus Java reads a 0->length stream, and does the only
sane thing it can: return null.

Thanks! Actually I tried that before but this method is giving memory
consumption problems as well. I try compressing images to save memory but
objects used in this method consume more memory than what it's freed so I
compression code is working fine but sometimes fails to complete due to the
lack of memory. Any advice on that? I tried Bitmap.Recycle() and disposing
used streams without success.

Best Regards,
 
Narcís Calvet
Steema Software
http://www.steema.com 
http://twitter.com/SteemaSoftware 
https://www.facebook.com/SteemaSoftware 


_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to