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.
I have updated to monotouch 6 and now CGBitmapContext constructor always fails with Invalid Handle exception.
Very easy to reproduce:
RectangleF bounds = new RectangleF(0,0,10,10);
byte data = new byte[(int)(bounds.Width * bounds.Height * 4)];
CGColorSpace space = CGColorSpace.CreateDeviceRGB();
CGBitmapContext c = new CGBitmapContext(data, (int)bounds.Width, (int)bounds.Height, 8, (int)bounds.Width * 4, space,CGBitmapFlags.None); // <- Exception
I can duplicate the issue.
Was the code working on earlier MT releases ? if so do you recall which version you were using before MT 6.0.
I get the same problem with iOS 5.1. OTOH it works if you use CGImageAlphaInfo instead of CGBitmapFlags
e.g. CGImageAlphaInfo.PremultipliedLast instead of CGBitmapFlags.None
for that matter CGBitmapFlags.PremultipliedLast works too
while CGBitmapFlags.None == CGBitmapFlags.ByteOrderDefault == 0 fails
I never noticed this before but it seems to be a (little) known fact .
Apple docs  says that None and SkipLast should be equivalent - but that's not what happens in real life. I submitted this "bad" documentation to Apple.
Based on this I do not think the None flag worked with earlier MT releases, so I'm closing the issue.
I didn't used this function since a long time and don't remember if used CGBitmapFlags.PremultipliedLast or CGBitmapFlags.None, so maybe it never worked.
Hmmm, it seems weird but a lot of values in both enums cause the same exception, as an example, if CGImageAlphaInfo.First (which corresponds to ARGB with no premultiplied alpha) is used it causes the exception.
This can be serious if those formats needed to be used.
Not every flags are supported on iOS  and even then if something is missing you'll need to tell Apple about it (MonoTouch just relay the refusal to create the context as an exception).
Ok, my bad, sorry for that :)