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

Author Topic: Problems converting a color-array into an image  (Read 3065 times)

0 Members and 1 Guest are viewing this topic.

TodesBrot

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Problems converting a color-array into an image
« 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, 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:


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Problems converting a color-array into an image
« Reply #1 on: May 13, 2014, 03:13:17 am »
Fixed here. If you want the fix either compile SFML.NET from source or wait for the 2.2 release.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

TodesBrot

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Problems converting a color-array into an image
« Reply #2 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!