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

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

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 15
    • View Profile
Saving Image Within A Rectangle
« on: December 06, 2019, 11:47:17 pm »
   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


  • SFML Team
  • Hero Member
  • *****
  • Posts: 9573
    • 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
Nightly Builds: https://www.nightlybuilds.ch/
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/