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

Author Topic: Resizing of an Image in SFML 2.5  (Read 1984 times)

0 Members and 1 Guest are viewing this topic.

Ago19

  • Newbie
  • *
  • Posts: 15
    • View Profile
Resizing of an Image in SFML 2.5
« on: February 15, 2022, 02:36:56 pm »
I know that I can't resize an Image in SFML 2.5.
I learning how to use SFML and I'm trying to make a program that reads every pixel of an Image then transforms it into an ASCII char. The problem is that if the image size is too big the program takes too long and also can't output the whole pixel line to the console. (because in the console you can only output a fixed amount of char before it goes to the new line).
What I'm trying to do is to resize an Image. I tryied with sf::Image, sf::Texture but I can't with any of those. The only thing that i can resize is an sf::Sprite but then I can't take each pixel of the sprite with getPixel(x,y).
Any suggestions?
Thanks

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Resizing of an Image in SFML 2.5
« Reply #1 on: February 15, 2022, 04:20:21 pm »
Once you have your sprite and have resized it you can draw it to sf::RenderTexture then use sf::RenderTexture::getTexture()::copyToImage() to get it back to an image object. It can be slow but might be fast enough for what you need.

Ago19

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Resizing of an Image in SFML 2.5
« Reply #2 on: February 16, 2022, 04:35:34 pm »
How do I drawn on sf::RenderTexture? And then how do I use sf::RenderTexture::...?
Could you write me some example code? thanks


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Resizing of an Image in SFML 2.5
« Reply #3 on: February 16, 2022, 04:50:34 pm »
You can find some examples in the official documentation: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1RenderTexture.php#details
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything