SFML community forums

Help => Graphics => Topic started by: cristaloleg on October 26, 2012, 07:40:34 am

Title: How to quickly draw image by pixel? SFML 2
Post by: cristaloleg on October 26, 2012, 07:40:34 am
I use this code:

sf :: Image image;
image.create(1024, 768, sf :: Color());

sf :: Texture texture;
texture.loadFromImage(image);

sf :: Sprite sprite(texture);

// some code here

for ( int i = 0; i < WIDTH; ++i )
        for ( int j = 0; j < HEIGHT; ++j )
                image.setPixel(i, j, f(t, i, j, image.getPixel(i, j)));
texture.loadFromImage(image);
 

But I think this isn't quick solution. Can You help?
 
Title: Re: How to quickly draw image by pixel? SFML 2
Post by: Laurent on October 26, 2012, 08:16:58 am
Why did you post in the C forum? ???

The fastest solution is to work on your own array (std::vector<sf::Uint8>), with fast direct access to pixels, rather than sf::Image.
Title: Re: How to quickly draw image by pixel? SFML 2
Post by: cristaloleg on October 26, 2012, 12:35:19 pm
thank's. sorry for mistake with partition