SFML community forums

Help => Graphics => Topic started by: HeinzK on January 24, 2025, 10:09:15 am

Title: 2.6.2 to 3.0 loadFromImage
Post by: HeinzK on January 24, 2025, 10:09:15 am
V2:
sf::Texture *pTextureX = new sf::Texture;
pTextureX->loadFromImage(*pTxu->pImage, *pIntRectTextureX);
V3:
sf::Texture *pTextureX = new sf::Texture;
pTextureX->loadFromImage(*pTxu->pImage, bRGB, *pIntRectTextureX);
.. bRGB (true or false) .. what's right for me?
Title: Re: 2.6.2 to 3.0 loadFromImage
Post by: eXpl0it3r on January 24, 2025, 11:01:50 am
Unless you use sRGB you want it to eb set to false, which is also the default value if you don't pass in an area, see the API documentation (https://www.sfml-dev.org/documentation/3.0.0/classsf_1_1Texture.html#a9d6d90f015446eecb9a1e4cef8dc17b1).

I highly recommend to either use stack variables or at least smart pointers (e.g. std::unique_ptr + std::make_unique) instead of doing manual memory management with new.