I can't see this mentioned in the documentation. Am I missing something obvious? Or does SFML really give you no option, forcing everything to be loaded as RGBA8888?

Searches on Google and the SFML forums have been unproductive.

  • \$\begingroup\$ I think I remeber beeing able to load other formats too. Do you have any particular code snippet which results in an error? \$\endgroup\$ – floAr Sep 13 '13 at 11:00
  • \$\begingroup\$ No, I do not. I remember doing some research and working with code, and either finding nothing or finding a way I thought would work, but when attempting it the memory usage was identical either way. I will try again shortly. \$\endgroup\$ – Carter81 Sep 13 '13 at 12:02
  • 1
    \$\begingroup\$ You might need to check if SFML can compress your RGBA8888 images on loading. Of course that means longer loading times and usually worse compression quality, but at least that is something to get you started. \$\endgroup\$ – Kromster Sep 16 '13 at 5:18

SFML, at least as of version 2 and as of this writing, uses stb_image (available here) to load image data, except on Android platforms. You can verify this by checking the source (Image.cpp and ImageLoader.cpp in particular).

Most of the documentation for stb_image is in the header file; SFML's particular version of it is here (be warned: it is large). However, while the header comments do point out some limitations for particular file formats, there's nothing in there that seems to imply RGBA8888 only (although for the PNG format, it sounds like you can only have 8-bit channels so RGBA4444 is probably out).

Thus, the short answer is: yes, but with some limitations depending on the file format.

  • \$\begingroup\$ I looked over the source a bit closer, and just to confirm: yes it only supports 8-bit formats, and yes it does optionally support alpha channel as well as other valid PNG format combinations such as indexed and gray scale. \$\endgroup\$ – user39686 Apr 29 '14 at 4:48
  • \$\begingroup\$ I liked to add that internally, SFML stores images as RGBA8888 because each pixel is a sf::Color which is 1 byte for each channel. \$\endgroup\$ – Xplane Sep 11 '14 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.