SFML community forums

Help => Graphics => Topic started by: 93interactive on September 10, 2009, 11:45:08 am

Title: Bug in 2.0 branch
Post by: 93interactive on September 10, 2009, 11:45:08 am
hello,

there is a bug in current revision of the 2.0 branch.

i have two gimp made 32 bit png files with alpha, both are 64 pixels high, one is less than 32 pixel wide, and the other more then 32 pixel.

if i set it up like (untested code ahead):

Code: [Select]

this->smallImage.LoadFromFile("small.png");
this->smallSprite.SetImage(smallImage);
this->smallSprite.SetOrigin(this->smallImage.GetWidth()*0.5f,this->smallImage.GetHeight()*0.5f);


this->bigImage.LoadFromFile("big.png");
this->bigSprite.SetImage(bigImage);
this->bigSprite.SetOrigin(this->bigImage.GetWidth()*0.5f,this->bigImage.GetHeight()*0.5f);


and then draw it with:

Code: [Select]

float x=100.0f;
float y=100.0f;

this->bigSprite.SetPosition(x,y);
this->RenderWindow->Draw(this->bigSprite);

x+=this->bigImage.GetWidth();

this->smallSprite.SetPosition(x,y);
this->RenderWindow->Draw(this->smallSprite);

x+=this->smallSprite.GetWidth();

this->bigSprite.SetPosition(x,y);
this->RenderWindow->Draw(this->bigSprite);


then the small sprite is rendered offsetted to the right, so either the SetOrigin() or the GetWidth() seems to fail on images < 32 pixels.

edit: if i just take the image smaller then 32 pixels in with and scale it in gimp to more then 32 pixels, it works.
Title: Bug in 2.0 branch
Post by: Laurent on September 10, 2009, 12:04:45 pm
Do you have a screenshot or an archive containing everything needed to run the test, so that we can understand the problem better?
Title: Bug in 2.0 branch
Post by: 93interactive on September 10, 2009, 01:06:19 pm
(http://93-interactive.com/sfml/FontError.jpeg)

the 1 and the dot are the images < 32 pixel, they are blitted too much to the right, as if SetOrigin() would have been ignored.

here is a stripped down visual c project:

SFMLDebug.zip (http://93-interactive.com/sfml/SFMLDebug.zip)
Title: Bug in 2.0 branch
Post by: Laurent on September 10, 2009, 02:02:06 pm
There's no bug in SFML, it's your algorithm that is wrong. To find the position of the next digit you add the size of the previous one, but you should add half its size + half the size of the next digit (this is because your positions are the centers of the digit; your algorithm would be valid if your sprites were aligned to left).

If you're not convinced try commenting all the "SetOrigin" calls: the problem disappears.
Title: Bug in 2.0 branch
Post by: 93interactive on September 10, 2009, 02:37:58 pm
:oops:  i'm so sorry

it made so much sense that it must be a bug only happening (or showing up) with images < 32 pixels  :wink:

thank you very much!