How to save texture to image using soil2 library

119 Views Asked by At

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.

1

There are 1 best solutions below

1
hpalo On

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).