SFML community forums
Help => Graphics => Topic started by: XBigTK13X on April 01, 2011, 12:57:42 am
-
I am loading a PNG file into an instance of Sprite and then calling draw. The image displays at the proper location, but also has a grey bounding box that is not part of the image itself. This box resizes with the sprite when the window is resized. How can this box be disabled/hidden?
Code where the error originates:
sf::Image sfi;
sf::Sprite sprite;
if (!sfi.LoadFromFile(filename))
{
Log::debug("Failed to load file");
return;
}
sprite.SetPosition(origin.x,origin.y);
sprite.SetImage(sfi);
target.Draw(sprite);
A screenshot showing the bounding box.
http://imgur.com/sEAsq
-
I'm a teammate of the OP and have new information. I just found a solution of calling SetSmooth(false) but not sure why that prevented the artifact. It'd be great if we still had the option of smoothing. Any ideas?
void ViewBase::drawImage(sf::RenderWindow & target, const std::string & filename, const Point & origin)
{
sf::Image sfi;
sfi.SetSmooth(false);
sf::Sprite sprite;
if (!sfi.LoadFromFile(filename))
{
Log::debug("Failed to load file");
return;
}
sprite.SetImage(sfi);
sprite.SetPosition(origin.x,origin.y);
target.Draw(sprite);
}
The image in question (as on disk, without the artifact created when displayed in SFML): (http://img130.imageshack.us/img130/7774/cursormask.png)
-
Try to make the graphical content of your image a little bit (5px or so) smaller than the canvas and make the rest completely transparent.
-
It's the stupid Bilinear filtering that Laurent set to be turned on by default. The gray border happens because it's blending the image with the surroundings.
-
I'm a teammate of the OP and have new information. I just found a solution of calling SetSmooth(false) but not sure why that prevented the artifact. It'd be great if we still had the option of smoothing. Any ideas?
void ViewBase::drawImage(sf::RenderWindow & target, const std::string & filename, const Point & origin)
{
sf::Image sfi;
sfi.SetSmooth(false);
sf::Sprite sprite;
if (!sfi.LoadFromFile(filename))
{
Log::debug("Failed to load file");
return;
}
sprite.SetImage(sfi);
sprite.SetPosition(origin.x,origin.y);
target.Draw(sprite);
}
The image in question (as on disk, without the artifact created when displayed in SFML): (http://img130.imageshack.us/img130/7774/cursormask.png)
This helped me. Thank you. :)