Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The code below is run in a seperate thread and causes exception at "rotatedImage.Compress(Bitmap.CompressFormat.Jpeg, quality, stream);" stating that it is trying to access a disposed Bitmap. Apparently, when scaledImage is assigned to rotatedImage, the corresponding native bitmap is disposed since scaledImage is not used after this point but the truth is rotatedImage points to the scaled image bitmap and thus the bitmap should not be disposed.
Bitmap scaledImage = BitmapFactory.DecodeFile(filePath, options);
Bitmap rotatedImage = null;
if (rotation != 0)
var matrix = new Matrix();
rotatedImage = Bitmap.CreateBitmap(scaledImage, 0, 0, scaledImage.Width,
scaledImage.Height, matrix, true);
rotatedImage = scaledImage;
int finalWidth = rotatedImage.Width;
int finalHeight = rotatedImage.Height;
using (var stream = new MemoryStream())
rotatedImage.Compress(Bitmap.CompressFormat.Jpeg, quality, stream);
finalImageByteArray = stream.ToArray();
Thank you for taking the time to submit the bug. We are unable to reproduce this issue from the description.
Can you let us know which version of Xamarin.Android and Visual Studio (or Xamarin Studio) you are using? Also, please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue.
The more information we have, the faster we can resolve the problem -- some guidelines can be found here: https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!