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

Author Topic: Screenshot part of renderWindow  (Read 924 times)

0 Members and 1 Guest are viewing this topic.

Soazul

  • Newbie
  • *
  • Posts: 2
    • View Profile
Screenshot part of renderWindow
« on: December 28, 2022, 03:42:12 am »
Hi, I have trouble understanding how to screenshot only part of the renderWindow. I currently understand how to screenshot the whole window. If anyone has any idea on how to approach this problem, please help me. Thank you.

What I currently have:
sf::Texture texture;
texture.create(1200, 675);
texture.update(renderWindow);
texture.copyToImage().saveToFile(filename + "-imagefilter.jpg");
« Last Edit: December 28, 2022, 01:48:09 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Screenshot part of renderWindow
« Reply #1 on: December 28, 2022, 01:48:01 pm »
Before calling saveToImage, you can call copy on the image and define the desired section.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Soazul

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Screenshot part of renderWindow
« Reply #2 on: December 28, 2022, 06:08:56 pm »
To clarify, do you mean saveToFile?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Screenshot part of renderWindow
« Reply #3 on: December 28, 2022, 07:07:55 pm »
Yes :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/