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

Author Topic: Saving Image Within A Rectangle  (Read 1217 times)

0 Members and 1 Guest are viewing this topic.

Birdron

  • Newbie
  • *
  • Posts: 17
    • View Profile
Saving Image Within A Rectangle
« on: December 06, 2019, 11:47:17 pm »
Hi,
   There is a method RenderWindow::capture which save all window as an image. Is it possible to save just those images which are inside a rectangleShape?
   I have attached an image, I just want to save the inner area. Which is a rectangleShape.

Thank you

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Saving Image Within A Rectangle
« Reply #1 on: December 07, 2019, 12:09:47 am »
capture() is deprecated, instead you should be using texture.update(window) and then texture.copyToImage().

As for your question, not that's not directly supported. You can do it by either rendering to a render texture only the part you want to save, or you could only save a section of the sf::Image (e.g. use image.copy() and then save the copied image).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything