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

Author Topic: sf::Texture to sf::Image  (Read 2453 times)

0 Members and 1 Guest are viewing this topic.

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
sf::Texture to sf::Image
« on: June 01, 2015, 07:02:37 pm »
HI! its possible get a sf::Image from a sf::Texture?? or best... its possible get the array of pixels of the texture without using sf::Image?

Thx!
dev@redneboa.es | WordPress | GitHub | YouTube

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10836
    • View Profile
    • development blog
    • Email
AW: sf::Texture to sf::Image
« Reply #2 on: June 01, 2015, 07:16:15 pm »
You can just use the sf::Image directly which will also provide a function to the pixel array.

Converting a texture to an image is expensive but can be done as well. See the documentation.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
Re: sf::Texture to sf::Image
« Reply #3 on: June 01, 2015, 07:20:55 pm »
Ooooppps!! i see te documentation but don't see these function hehe :( :P  Thx!!

eXpl0it3r the problem is that i load all how sf::Texture why all calls in SFML require a sf::Texture... ¿is best preload with sf::Image and use sf::Texture when call a function? thx for all ;)

I need array of pixels for save it into a file.


P.S: Sry for my bad english
dev@redneboa.es | WordPress | GitHub | YouTube

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10836
    • View Profile
    • development blog
    • Email
Re: sf::Texture to sf::Image
« Reply #4 on: June 01, 2015, 07:55:13 pm »
the problem is that i load all how sf::Texture why all calls in SFML require a sf::Texture... ¿is best preload with sf::Image and use sf::Texture when call a function? thx for all ;)
Yes, you load the image into an sf::Image and if you need to draw it, load it into an sf::Texture. You do each of these operations only once!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/