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

Author Topic: getTexture for a SubRect / sprite  (Read 1409 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
getTexture for a SubRect / sprite
« on: July 20, 2012, 02:47:53 pm »
Hi

I have loads of sprites, all derived from large tiles using SetSubRect. Now I need to be able to save to file each of these sprites. I can do a mySprite.getTexture and copy this to an sf::Image...but this is the entire tile for this sprite - not just the data for the small sub-rect.

Any ideas how to achieve this??

Many Thanks
Ed
SFML 2.1

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10914
    • View Profile
    • development blog
    • Email
Re: getTexture for a SubRect / sprite
« Reply #1 on: July 20, 2012, 03:09:42 pm »
Draw them all to a sf::RenderTexture retrieve the texture, convert to a image and save it. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: getTexture for a SubRect / sprite
« Reply #2 on: July 20, 2012, 04:26:19 pm »
I managed to do it using a temporary sf::Image, copying data from a texture using copyToImage, and then saving it. It works perfectly :)

Thanks!
SFML 2.1