SFML community forums

Bindings - other languages => DotNet => Topic started by: TodesBrot on May 13, 2014, 01:34:31 am

Title: Problems converting a color-array into an image
Post by: TodesBrot on May 13, 2014, 01:34:31 am
I know that this is the same issue as http://en.sfml-dev.org/forums/index.php?topic=14861.0 (http://en.sfml-dev.org/forums/index.php?topic=14861.0), but it does not seem to be answered by an official developer and it lacks some clarification.

The issue is that a two-dimensional array of colors can't get properly converted into an image.
Allow me to show an example:

int width = 128;
int height = 128;

Color[,] pixels = new Color[width, height];

for (int x = 0; x < width; x++)
{
        for (int y = 0; y < height; y++)
        {
                pixels[x, y] = new Color((byte)x, 0, (byte)y);
        }
}

Image img = new Image(pixels);

This code should create a gradient that gets red to the right and blue to the bottom.
But against my expectations, it gets red to the bottom and blue to the right.

If the width and height variables don't have the same values, the results look a little different.
Example with width 73 and height 200:

(https://dl.dropboxusercontent.com/s/yli4hi76yov8z1l/imagecolor.png?dl=1&token_hash=AAH3vVEWCWvF9Y7kgsEwlRGWbe4-vJk8xjbHfY8dAzo2Ig&expiry=1399941152)
Title: Re: Problems converting a color-array into an image
Post by: zsbzsb on May 13, 2014, 03:13:17 am
Fixed here (https://github.com/SFML/SFML.Net/commit/46df00e8c0288dbaf9fddb901de5f6e603a470c7). If you want the fix either compile SFML.NET from source or wait for the 2.2 release.
Title: Re: Problems converting a color-array into an image
Post by: TodesBrot on May 13, 2014, 01:44:58 pm
Oh, I didn't see that. I thought it wasn't fixed because the other thread didn't have any replies regarding a fix. Thanks for letting me know!