简体   繁体   中英

How to save texture to image using soil2 library

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM