0

I am trying to save texture to a image using SOIL2 library.

            int _width, _height;

            unsigned char* _image = SOIL_load_image("C:\\Temp\\RED.png", &_width, &_height, 0, SOIL_LOAD_RGB);

            int save_result = SOIL_save_image
            (
                "C:\\temp\\atlas.png",
                SOIL_SAVE_TYPE_PNG,
                _width, _height, GL_RGB,
                _image
            );

But image does not gets saved the return values from the saved function is 0.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Summit
  • 2,112
  • 2
  • 12
  • 36

1 Answers1

2

In my case (GL_RGBA) I needed to set the channels parameter to 4 (not GL_RGBA) to get it working. In your case, you probably need to change it to 3 (not GL_RGB).

hpalo
  • 21
  • 3
  • 1
    Exactly. If you look at the soil library's source code (https://github.com/SpartanJ/SOIL2), the _channels_ parameter just specifies the number of channels (and assumes RGB(A) layout). – Heinrich supports Monica Feb 02 '23 at 16:35