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

Author Topic: How to quickly draw image by pixel? SFML 2  (Read 3225 times)

0 Members and 1 Guest are viewing this topic.

cristaloleg

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
How to quickly draw image by pixel? SFML 2
« 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?
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to quickly draw image by pixel? SFML 2
« Reply #1 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.
Laurent Gomila - SFML developer

cristaloleg

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: How to quickly draw image by pixel? SFML 2
« Reply #2 on: October 26, 2012, 12:35:19 pm »
thank's. sorry for mistake with partition

 

anything