【问题标题】:SOIL Image size土壤图像尺寸
【发布时间】:2018-11-19 20:38:15
【问题描述】:

我能否以某种方式获取图像的大小(任何 SOIL 支持的)?

我知道图像文件中有不同的标题来定义这些大小。但是 SOIL 有什么函数可以获取图像大小吗?

【问题讨论】:

    标签: c++ opengl soil


    【解决方案1】:

    SOIL_load_image() 将使用图像的尺寸填充宽度/高度参数,尽管这样做会完全加载图像:

    /**
        Loads an image from disk into an array of unsigned chars.
        Note that *channels return the original channel count of the
        image.  If force_channels was other than SOIL_LOAD_AUTO,
        the resulting image has force_channels, but *channels may be
        different (if the original image had a different channel
        count).
        \return 0 if failed, otherwise returns 1
    **/
    unsigned char*
        SOIL_load_image
        (
            const char *filename,
            int *width, int *height, int *channels,
            int force_channels
        );
    

    不加载完整图像的底层stb_image.hhas routines

    // get image dimensions & components without fully decoding
    STBIDEF int      stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
    STBIDEF int      stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
    STBIDEF int      stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len);
    STBIDEF int      stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user);
    
    #ifndef STBI_NO_STDIO
    STBIDEF int      stbi_info               (char const *filename,     int *x, int *y, int *comp);
    STBIDEF int      stbi_info_from_file     (FILE *f,                  int *x, int *y, int *comp);
    STBIDEF int      stbi_is_16_bit          (char const *filename);
    STBIDEF int      stbi_is_16_bit_from_file(FILE *f);
    #endif
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多