Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Image constructor crash  (Read 2972 times)

0 Members and 2 Guests are viewing this topic.

Gonzilla

  • Newbie
  • *
  • Posts: 21
    • View Profile
Image constructor crash
« 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
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Image constructor crash
« Reply #1 on: May 10, 2012, 10:46:14 pm »
It's fixed, thanks.
Laurent Gomila - SFML developer

Gonzilla

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Image constructor crash
« Reply #2 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);
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Image constructor crash
« Reply #3 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?
Laurent Gomila - SFML developer

Gonzilla

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Image constructor crash
« Reply #4 on: May 11, 2012, 11:15:59 am »
Yes please. In .NET every exception is nicer than an immediate close/crash of the application ;)