简体   繁体   English

如何使用 soil2 库将纹理保存到图像

[英]How to save texture to image using soil2 library

I am trying to save texture to a image using SOIL2 library.我正在尝试使用 SOIL2 库将纹理保存到图像中。

            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.但是图像没有保存,保存的 function 的返回值为 0。

In my case (GL_RGBA) I needed to set the channels parameter to 4 (not GL_RGBA) to get it working.在我的例子中(GL_RGBA),我需要将通道参数设置为 4(不是 GL_RGBA)以使其正常工作。 In your case, you probably need to change it to 3 (not GL_RGB).在您的情况下,您可能需要将其更改为 3(不是 GL_RGB)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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