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

Poll

A handy feature?

Yes
1 (50%)
No
1 (50%)

Total Members Voted: 2

Voting closed: November 25, 2010, 10:22:18 am

Author Topic: Copy a Sprite onto an Image  (Read 3041 times)

0 Members and 1 Guest are viewing this topic.

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Copy a Sprite onto an Image
« on: November 25, 2010, 10:22:18 am »
You know how you can copy a sf::Image onto another sf::Image? This is a handy feature I'm using quite a bit in the game I'm making. However, I feel being able to copy an sf::Sprite onto a sf::Image would be extremely useful. When you copy a sf::Image you don't get the rotation, scale factors or anything. Because of this, instead of just using Rotate(), I'm going to have to use about 5 different images in my game. I think this would be a useful addition.

So basically, I would like to copy a sf::Sprite onto a sf::Image. It's just a suggestion :)

Awesome library, really simple, keep it up!
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Copy a Sprite onto an Image
« Reply #1 on: November 25, 2010, 10:47:43 am »
So it's not a simple pixel copy, the sprite has to go through all the rendering steps (transform, rasterization, pixel shader, alpha blending, ...), which are all done by the graphics card. So it's not the simple pixel-based blit that SDL provides, it's a lot more complex.

Rendering to an image (just like to a window) is already implemented in SFML 2, with the RenderImage class.

Note that for simple copy, you can use the Image::Copy function. It's a simple pixel copy, but it's enough if you just want to compose an image from several ones. And it handles transparency ;)
Laurent Gomila - SFML developer

Stew_822

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://circean-studios.co.cc
    • Email
Copy a Sprite onto an Image
« Reply #2 on: November 25, 2010, 08:46:01 pm »
There we go then :). You've already done it! I actually did have a look at the SFML 2 doc before I posted, but I only looked in the sf::Image class.

Well, thanks for such an awesome library and thanks for responding to my post :)
It's better to keep your mouth shut and give the impression that you're stupid than to open it and remove all doubt.