gpt4 book ai didi

c++ - 土壤图像尺寸

转载 作者:行者123 更新时间:2023-11-30 04:54:54 26 4
gpt4 key购买 nike

我能否以某种方式获取图像(任何 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com