Bug 4337 - libgdiplus: do not throw exception when inverting non-invertible matrix
Summary: libgdiplus: do not throw exception when inverting non-invertible matrix
Status: RESOLVED ANSWERED
Alias: None
Product: Class Libraries
Classification: Mono
Component: libgdiplus ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Duncan Mak
URL:
Depends on:
Blocks:
 
Reported: 2012-04-08 13:57 UTC by Jan Iven
Modified: 2018-03-13 15:31 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 GitHub or Developer Community 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.

Related Links:
Status:
RESOLVED ANSWERED

Description Jan Iven 2012-04-08 13:57:58 UTC
When presented with a matrix that can't be inverted, MS .net Matrix.Invert() seems to silently ignore that error. Mono libgdiplus throws an exception.

See https://bugs.launchpad.net/purple-pen/+bug/580619, the program in question runs happily on Windows. Mono says:

System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000]
  at System.Drawing.Drawing2D.Matrix.Invert () [0x00000]

Patching  the program to not Invert() the matrix unless IsInvertible() removes the exception on Mono as well, but should not be required..

Seen with Ubuntu Oneiric packaged libgdiplus-2.10-2
Comment 1 Hugh Bellamy 2017-09-26 17:44:07 UTC
The following code throws an ArgumentException on Windows: https://dotnetfiddle.net/R7ym4P

```
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Diagnostics;
					
public class Program
{
	
	public static void Main()
	{
		var matrix = new Matrix(123, 24, 82, 16, 47, 30);
		Debug.Assert(!matrix.IsInvertible);
		
		matrix.Invert();
	}
}
```

I think this issue can be closed as both Windows and Mono have the same behaviour.