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

Author Topic: Issue with converting Texture to Image  (Read 1495 times)

0 Members and 1 Guest are viewing this topic.

TheArmoredPanda

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with converting Texture to Image
« on: September 17, 2023, 09:17:08 pm »
Hello I am trying to convert from a texture to an image, and I have combed the sfml forums and sfml documentation and the only answer given is texture.copyFromImage(). However, this does not work, as I get an error message claiming class"sf::RenderTexture" has no member "copyFromImage". In order to make sure I wasnt missing something, I included every Sfml graphics header file. Has sfml been updated or am I doing something wrong?

Ruckamongus

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Issue with converting Texture to Image
« Reply #1 on: September 18, 2023, 12:38:39 am »
https://www.sfml-dev.org/documentation/2.6.0/classsf_1_1Texture.php

https://www.sfml-dev.org/documentation/2.6.0/classsf_1_1RenderTexture.php

An sf::Texture and sf::RenderTexture are different things. You're looking for Texture.copyFromImage() not RenderTexture.copyFromImage().

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
Re: Issue with converting Texture to Image
« Reply #2 on: September 18, 2023, 01:58:53 am »
I believe it's "copyToImage" not "copyFromImage".

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Issue with converting Texture to Image
« Reply #3 on: September 18, 2023, 10:49:57 am »
If you have a texture:
Image img = tex.copyToTexture();

If you have a rendertexture:
Image img = rendtex.getTexture().copyToTexture();

 

anything