SFML community forums

Bindings - other languages => DotNet => Topic started by: Gonzilla on May 10, 2012, 10:20:33 pm

Title: Image constructor crash
Post by: Gonzilla on May 10, 2012, 10:20:33 pm
Image img = new Image(0,0); //crash without any error message
Image img = new Image(0,0, Color.Red); //crash without any error message
Image img = new Image(0,0, null); //working
 
Title: Re: Image constructor crash
Post by: Laurent on May 10, 2012, 10:46:14 pm
It's fixed, thanks.
Title: Re: Image constructor crash
Post by: Gonzilla on May 11, 2012, 10:55:08 am
Also I found a bug in the Image class.

var colors = new Color[2,2];
colors[0, 0] = Color.Red;
colors[0, 1] = Color.Yellow;
colors[1, 0] = Color.Green;
colors[1, 1] = Color.Black;

var image = new Image(colors);

//Working
var pixel = image.GetPixel(0, 1);
//Crash without any message because it's out of bound
var pixel2 = image.GetPixel(0, 2);

//Working
image.SetPixel(0, 1, Color.White);

//Crash without any message because it's out of bound
image.SetPixel(0, 2, Color.White);
 
Title: Re: Image constructor crash
Post by: Laurent on May 11, 2012, 10:58:41 am
Yep, SFML doesn't check out of bounds access.

This behaviour is ok for C++, but maybe I should handle it in SFML.Net, and throw an exception instead?
Title: Re: Image constructor crash
Post by: Gonzilla on May 11, 2012, 11:15:59 am
Yes please. In .NET every exception is nicer than an immediate close/crash of the application ;)