Go to the documentation of this file.
8 #ifndef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 1
19 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
27 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
31 #define IMSZ_EXPORT __declspec(dllimport)
34 #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
35 #define IMSZ_EXPORT __attribute__ ((visibility ("default")))
37 #define IMSZ_EXPORT extern
88 #define IMSZ_INIT { .width = (uint64_t)0, .height = (uint64_t)0, .format = 0 }
134 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__DOXYGEN__)
155 #define imsz_from_file(fp, info_ptr) imsz_from_fd(_fileno((fp)), (info_ptr))
157 #define imsz_2_(arg1, arg2) \
159 wchar_t*: imsz_from_pathw((const wchar_t*)(arg1), (arg2)), \
160 const wchar_t*: imsz_from_pathw((const wchar_t*)(arg1), (arg2)), \
161 char*: imsz_from_path((const char*)(arg1), (arg2)), \
162 const char*: imsz_from_path((const char*)(arg1), (arg2)), \
163 FILE*: imsz_from_file((FILE*)(arg1), (arg2)), \
164 HANDLE: imsz_from_handle((HANDLE)(arg1), (arg2)), \
165 int: imsz_from_fd((intptr_t)(arg1), (arg2)) \
168 #define imsz_from_file(fp, info_ptr) imsz_from_fd(fileno((fp)), (info_ptr))
170 #define imsz_2_(arg1, arg2) \
172 char*: imsz_from_path((const char*)(arg1), (arg2)), \
173 const char*: imsz_from_path((const char*)(arg1), (arg2)), \
174 FILE*: imsz_from_file((FILE*)(arg1), (arg2)), \
175 int: imsz_from_fd((intptr_t)(arg1), (arg2)) \
186 #define imsz_3_(arg1, arg2, arg3) \
187 imsz_from_buffer((arg1), (arg2), (arg3))
189 #define imsz_va_dispatch_(arg1, arg2, arg3, arg4, ...) arg4
195 #if defined(__cplusplus) || defined(__DOXYGEN__)
207 inline int imsz(
const void *buf,
size_t len,
ImInfo *info_ptr) {
225 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__DOXYGEN__)
226 inline int imsz(
const wchar_t *path,
ImInfo *info_ptr) {
242 #if !defined(__cplusplus) || defined(__DOXYGEN__)
261 #define imsz(...) imsz_va_dispatch_(__VA_ARGS__, imsz_3_, imsz_2_, imsz_error_)(__VA_ARGS__)
int imsz_from_fd(int fd, ImInfo *info_ptr)
const char * imsz_format_name(unsigned int format)
@ IMSZ_GIF
Graphics Interchange Format files in version GIF87a or GIF89a.
Definition: imsz.h:61
@ IMSZ_QOI
Quite OK Image format files.
Definition: imsz.h:66
uint64_t width
Width of the image.
Definition: imsz.h:92
int imsz(const char *path, ImInfo *info_ptr)
Alias of imsz_from_path()
Definition: imsz.h:200
@ IMSZ_OK
No error.
Definition: imsz.h:53
@ IMSZ_OpenEXR
OpenEXR files.
Definition: imsz.h:72
@ IMSZ_PNG
Portable Network Graphics files. Requires the first chunk to be IHDR.
Definition: imsz.h:62
@ IMSZ_VTF
Valve Texture Format.
Definition: imsz.h:79
@ IMSZ_TIFF
Tag Image File Format. Supports big endian and little endian TIFF files.
Definition: imsz.h:71
@ IMSZ_DDS
DirectDraw Surface files.
Definition: imsz.h:75
@ IMSZ_HEIF
HEIC/HEIF files.
Definition: imsz.h:76
struct ImInfo ImInfo
The width, height and format of an image.
#define imsz_from_file(fp, info_ptr)
@ IMSZ_JP2K
JPEG 2000 files.
Definition: imsz.h:77
@ IMSZ_XCF
GIMP files.
Definition: imsz.h:68
@ IMSZ_DIB
Device-Independent bitmap files.
Definition: imsz.h:78
uint64_t height
Height of the image.
Definition: imsz.h:93
int imsz_from_buffer(const void *buf, size_t len, ImInfo *info_ptr)
@ IMSZ_ERR_IO
IO error happened, but no OS error (errno or WIndows error code) was reported. (Classic should never ...
Definition: imsz.h:54
The width, height and format of an image.
Definition: imsz.h:91
unsigned int format
Values from ImFormat.
Definition: imsz.h:103
@ IMSZ_JPEG
Joint Photographic Experts Group files.
Definition: imsz.h:64
@ IMSZ_PCX
PiCture eXchange files.
Definition: imsz.h:73
@ IMSZ_PSD
Adobe Photoshop files.
Definition: imsz.h:67
@ IMSZ_TGA
TARGA (Truevision Advanced Raster Graphics Adapter) files.
Definition: imsz.h:74
ImError
Error values.
Definition: imsz.h:52
ImFormat
All supported image formats.
Definition: imsz.h:60
int imsz_from_path(const char *path, ImInfo *info_ptr)
@ IMSZ_ERR_PARSER
File format was detected, but there was an error parsing the file. ImInfo::format will be set to the ...
Definition: imsz.h:55
const wchar_t * imsz_format_namew(unsigned int format)
@ IMSZ_ERR_UNSUPPORTED
File format is not supported.
Definition: imsz.h:56
@ IMSZ_BMP
Windows Bitmap, both for Windows 2.0 (BITMAPCOREHEADER) and for newer versions (BITMAPINFOHEADER).
Definition: imsz.h:63
int imsz_from_pathw(const wchar_t *path, ImInfo *info_ptr)
@ IMSZ_WEBP
WebP files. Supported sub-formats: VP8, VP8L, VP8X.
Definition: imsz.h:65
@ IMSZ_AVIF
AV1 Image File Format.
Definition: imsz.h:70
@ IMSZ_ICO
ICO files can contain multiple images. This returns the dimensions of the biggest image in the file.
Definition: imsz.h:69
int imsz_from_handle(HANDLE hnd, ImInfo *info_ptr)