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

Author Topic: Sprite is blurry  (Read 2472 times)

0 Members and 1 Guest are viewing this topic.

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Sprite is blurry
« on: April 15, 2010, 11:32:01 pm »
I'm experimenting with the SFML and wrote a sample program to display a sprite.

This is the sprite (as a BMP, but PNG produces the same problem):


And this is the output:


But of course, I would expect this:


So, why is it displayed so blurry?

This is my code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow screen(sf::VideoMode(100, 50, 32), "Test");

sf::Image image;
image.LoadFromFile("Mario.png");

sf::Sprite sprite;
sprite.SetImage(image);

while (screen.IsOpened())
{
sf::Event event;

while (screen.GetEvent(event))
{
if (event.Type == sf::Event::Closed)
screen.Close();
}

screen.Clear(sf::Color(0, 127, 127));
screen.Draw(sprite);

screen.Display();
}
}

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Sprite is blurry
« Reply #1 on: April 15, 2010, 11:34:53 pm »
After loading the image from the file add this line:

image.SetSmooth(false);

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Sprite is blurry
« Reply #2 on: April 15, 2010, 11:40:43 pm »
Oh great! Thanks a lot.