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.
In Apple iOS:
gives the CORRECT result:
[0.91, 0, 0, 1, -8.66, 0]
In Xamarin MonoTouch (v 6.0.6):
gives an INCORRECT result:
xx:0.91 yx:0.0 xy:0.0 yy:1.0 x0:-7.9 y0:0.0
ie it's -7.9 instead of -8.66
It took me ages to find this bug and obviously may cause unpredictable results.
I have just paid $399 for Xamarin today and found this bug on the first day! This is VERY concerning about
whether we can use Xamarin in our company now. Please re-assure me you will fix this quickly.
*** Bug 8389 has been marked as a duplicate of this bug. ***
For historical reasons (that I'm still digging, it predates Xamarin) MonoTouch does not multiple the matrices in the same order as CoreGraphics. It's also a type that is entirely managed (it does not p/invoke CoreGraphics).
In that case it means the scale is applied to the translation .
The immediate workaround is to invert the operations, like below. That won't scale the translation and give you the same result as an ObjC app.
var transform = CGAffineTransform.MakeTranslation (-8.66f, 0.0f);
var scale = CGAffineTransform.MakeScale (0.91f, 1.0f);
var t2 = CGAffineTransform.Multiply (scale, transform);
xx:0.91 yx:0.0 xy:0.0 yy:1.0 x0:-8.66 y0:0.0
I'll update the bug once I have more information the original decision(s).
 other libraries, like Cairo use this model, GDI+ has a parameter  that allow you to prepend (default) or append the operation.
Thanks for the workaround, but this must be fixed or people are always at risk from inconsistent behaviour with native iPhone, and will be wasting hours of development time debugging it (as I did).
This is the sort of bug that causes Space Shuttles to crash!
See also bug #7832.
This is a known issue. Fixing it, to match CoreGraphics, would cause issues to every existing applications, which are less likely to be fully tested (after a MonoTouch update) than newly developed applications.
I want to add to this discussion that the MonoTouch API is currently designed to alter the caller.
Affects "foo", and does so by performing:
this = this.Multiply (MakeScale ());
The Objective-C APIs on the other hand are given one source affine, parameters and return a new one.
So it is not an exact match to the API. What we could provide is one where the semantics are more obvious as static methods:
static CGAffineTransform Scale (CGAffineTransform source, float sx, flaot sy)
OK, I understand the problem of changing it now it's out there but providing an alternate API to match Core Graphics as suggested by Miguel de Icaza is a good suggestion.
You could mark the current API as "deprecated" so have a good chance of seeing issue when they start looking for the API.
I've been having a similar issue with the CGAffineTransform Rotate method, it's causing a translation to occur which doesn't happen in the native iOS CoreGraphics.
transform.Translate (0, newSize.Height);
transform.Rotate (-3.14159f / 2.0f);
gives a different TX, TY result to:
transform = CGAffineTransformTranslate(transform, 0, newSize.height);
transform = CGAffineTransformRotate(transform, -M_PI_2);
The only reason I worked it out was because I'm converting a project to Xamarin and I could debug from XCode to see the differences.
This has cost me about 6 hours of work!
I can create a workaround but this has to be fixed or deprecated.
A new overload has been introduced that behaves like the native CGAffineTransformScale function.
See bug #19341 for more information.
@Dan: I've also introduced equivalent overloads for Rotate and Translate.