SFML community forums

Help => Graphics => Topic started by: mayou on April 29, 2013, 09:54:45 pm

Title: My sprites are not the same as input file
Post by: mayou on April 29, 2013, 09:54:45 pm
Hi all,

i just start to learn your API, and I just meet a display problem.
When SFML draws a sprite in the window it's not the same as input :
My source image :
(http://dev.mayou.fr/wp-content/uploads/2013/04/brick_.png)
My SFML app :
(http://dev.mayou.fr/wp-content/uploads/2013/04/snapshot1.png)

Why ?

Here is my code :

#!/usr/bin/python
# -*- coding: utf-8 -*-

from PySFML import sf

brick_image = sf.Image()
brick_image.LoadFromFile("brick_.png")

window = sf.RenderWindow(sf.VideoMode(320,240,32), "SFML")

while True:

        window.Clear()

        for j in range(0,24) :
                for i in range(0,16) :
                        sprite = sf.Sprite(brick_image)
                        sprite.SetPosition(i * 20, j * 10)
                        idx = (i+j)%2
                        sprite.SetSubRect(sf.IntRect(20 * idx, 0, 20 + 20 * idx, 10))
                        window.Draw(sprite)

        window.Display()

Thanks in advance.
Title: Re: My sprites are not the same as input file
Post by: G. on April 29, 2013, 10:08:29 pm
Hi, it's 1.6 right?

In 1.6 images are smoothed by default, try using SetSmooth(false) on your brick_image.
Title: Re: My sprites are not the same as input file
Post by: mayou on April 29, 2013, 10:34:28 pm
Yup, it is 1.6... may I upgrade to 2.0 ?

Unfortunately
brick_image = sf.Image()
brick_image.LoadFromFile("brick_.png")
brick_image.SetSmooth(False)
or
brick_image = sf.Image()
brick_image.SetSmooth(False)
brick_image.LoadFromFile("brick_.png")
do not change anything.
Title: Re: My sprites are not the same as input file
Post by: G. on April 30, 2013, 12:01:38 am
Someone on this thread from 2010 (http://en.sfml-dev.org/forums/index.php?topic=3451.0) said that SetSmooth wasn't working in the 1.6 release, maybe that's your problem.

I've never used SFML with python so I may not be the best person to give you advice, but switching to 2.0 is a good idea.