source: opengl-game/stb_image.h@ e856d62

feature/imgui-sdl points-test
Last change on this file since e856d62 was 485424b, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 7 years ago

Add support for loading and applying texture and add a square to the scene with a demo texture

  • Property mode set to 100644
File size: 5.8 KB
Line 
1#ifndef STBI_INCLUDE_STB_IMAGE_H
2#define STBI_INCLUDE_STB_IMAGE_H
3
4#ifndef STBI_NO_STDIO
5#include <stdio.h>
6#endif
7
8#define STBI_VERSION 1
9
10enum
11{
12 STBI_default = 0, // only used for desired_channels
13
14 STBI_grey = 1,
15 STBI_grey_alpha = 2,
16 STBI_rgb = 3,
17 STBI_rgb_alpha = 4
18};
19
20typedef unsigned char stbi_uc;
21typedef unsigned short stbi_us;
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#ifdef STB_IMAGE_STATIC
28#define STBIDEF static
29#else
30#define STBIDEF extern
31#endif
32
33//////////////////////////////////////////////////////////////////////////////
34//
35// PRIMARY API - works on images of any type
36//
37
38//
39// load image by filename, open file, or memory buffer
40//
41
42typedef struct
43{
44 int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read
45 void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
46 int (*eof) (void *user); // returns nonzero if we are at end of file/data
47} stbi_io_callbacks;
48
49////////////////////////////////////
50//
51// 8-bits-per-channel interface
52//
53
54STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels);
55STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels);
56
57#ifndef STBI_NO_STDIO
58STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
59STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
60// for stbi_load_from_file, file pointer is left pointing immediately after image
61#endif
62
63////////////////////////////////////
64//
65// 16-bits-per-channel interface
66//
67
68STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
69STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels);
70
71#ifndef STBI_NO_STDIO
72STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
73STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
74#endif
75
76////////////////////////////////////
77//
78// float-per-channel interface
79//
80#ifndef STBI_NO_LINEAR
81 STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
82 STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels);
83
84 #ifndef STBI_NO_STDIO
85 STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
86 STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
87 #endif
88#endif
89
90#ifndef STBI_NO_HDR
91 STBIDEF void stbi_hdr_to_ldr_gamma(float gamma);
92 STBIDEF void stbi_hdr_to_ldr_scale(float scale);
93#endif // STBI_NO_HDR
94
95#ifndef STBI_NO_LINEAR
96 STBIDEF void stbi_ldr_to_hdr_gamma(float gamma);
97 STBIDEF void stbi_ldr_to_hdr_scale(float scale);
98#endif // STBI_NO_LINEAR
99
100// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
101STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
102STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
103#ifndef STBI_NO_STDIO
104STBIDEF int stbi_is_hdr (char const *filename);
105STBIDEF int stbi_is_hdr_from_file(FILE *f);
106#endif // STBI_NO_STDIO
107
108
109// get a VERY brief reason for failure
110// NOT THREADSAFE
111STBIDEF const char *stbi_failure_reason (void);
112
113// free the loaded image -- this is just free()
114STBIDEF void stbi_image_free (void *retval_from_stbi_load);
115
116// get image dimensions & components without fully decoding
117STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
118STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
119
120#ifndef STBI_NO_STDIO
121STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp);
122STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp);
123
124#endif
125
126
127
128// for image formats that explicitly notate that they have premultiplied alpha,
129// we just return the colors as stored in the file. set this flag to force
130// unpremultiplication. results are undefined if the unpremultiply overflow.
131STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
132
133// indicate whether we should process iphone images back to canonical format,
134// or just pass them through "as-is"
135STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
136
137// flip the image vertically, so the first pixel in the output array is the bottom left
138STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
139
140// ZLIB client - used by PNG, available for other purposes
141
142STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
143STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);
144STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
145STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
146
147STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
148STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif
Note: See TracBrowser for help on using the repository browser.