作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我能否以某种方式获取图像(任何 SOIL 支持)的大小?
我知道图像文件中有不同的 header 来定义这些尺寸。但是 SOIL 有什么函数可以获取图像大小吗?
最佳答案
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.h
has 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
关于c++ - 土壤图像尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53382286/
我可以加载 725x483 jpg 纹理但不能加载 725x544 代码: texId = SOIL_load_OGL_texture(fileName, SOIL_LOAD_AUTO,
我正在尝试使用 SOIL 加载纹理文件。我尝试从项目文件加载图像,还尝试从文件系统加载图像。当我尝试从项目 SOIL_last_result() 加载我的图像时,出现错误: Unable to ope
我是一名优秀的程序员,十分优秀!