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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - TodesBrot

Pages: [1]
1
DotNet / 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:


2
Graphics / Image distortion
« on: November 15, 2013, 09:59:39 pm »
I found a bug when displaying a sprite. It looks like this:



And it should look like this:



It happens when the Position.X/Y value is near .50050
I could recreate it with this little program, you can use any path that leads to an image instead of "image.png". The RenderTexture is just for scaling. It also works without the RenderTexture, but then the bug doesn't happen when it's scaled.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;

namespace distortionrecreationtest
{
    static class Program
    {
        static RenderWindow Window = new RenderWindow(new VideoMode(300, 200), "");

        static void Main(string[] args)
        {
            Window.Clear(Color.White);

            RenderTexture r = new RenderTexture(300, 200);

            Sprite s = new Sprite(new Texture("image.png"));
            s.Position = new Vector2f(0.50050f, 0.50050f);
            r.Draw(s);

            r.Display();

            s = new Sprite(r.Texture);
            s.Scale = new Vector2f(5, 5);
            Window.Draw(s);

            Window.Display();

            Window.Closed += Closed;

            while (Window.IsOpen())
            {
                Window.DispatchEvents();
            }
        }

        static void Closed(object sender, EventArgs e)
        {
            Window.Close();
        }
    }
}

Pages: [1]
anything