SFML community forums
General => General discussions => Topic started by: tsarek on January 10, 2009, 05:10:00 pm
-
Sorry for the bad English.
Noticed a bug, when using void sf:: Sprite:: SetImage (const Image & Img).
Using SFML 1.3, openSuse 11.0, freeglut 060903-133.1, mesa 7.0.3-35.1, ati radeon 9660
If the previous sprite size is less than the new image size, the new image cropped to fit the sprite size.
Example:
sf::Image image1;
image.LoadFromFile( "image1.png" );
sf::Image image2;
image.LoadFromFile( "image2.png" ); // Size of image1 is less than size of image2
sf::Sprite sprite( image1 );
...
...
sprite.SetImage( image2 ); // Sprite size not change
Thanks for the SFML library.
-
That's not a bug. It runs the way Laurent wanted.
-
Why?
////////////////////////////////////////////////////////////
/// Set the image of the sprite
////////////////////////////////////////////////////////////
void Sprite::SetImage(const Image& Img)
{
// If there was no source image before, adjust the rectangle
// if (!myImage) TODO comment this and all right
SetSubRect(IntRect(0, 0, Img.GetWidth(), Img.GetHeight()));
// Assign the new image
myImage = &Img;
}
-
Because:
http://www.sfml-dev.org/forum/viewtopic.php?t=821
-
Hm, when paint in a loop of tiles of various sizes to better initialize the same sprite different picture than each time to create a new sprite.
Please, write in the docs, that the sprites have constant size.
I have long searched for the cause, has not yet looked for source of library.
-
And more.
If the new picture is larger, sometimes around the sprites appear color artifacts.
It may be coincidence to check the size of pictures in SetImage?
-
Please, write in the docs, that the sprites have constant size.
So I'd have to do this for every function of sf::Sprite, as they also don't change its subrect. And I would even have to specify that every accessor doesn't change the other attributes... ;)