MCPcopy Create free account
hub / github.com/DentonW/DevIL / readpng_init

Function readpng_init

DevIL/src-IL/src/il_png.cpp:203–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203ILint readpng_init()
204{
205 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, png_error_func, png_warn_func);
206 if (!png_ptr)
207 return 4; /* out of memory */
208
209 info_ptr = png_create_info_struct(png_ptr);
210 if (!info_ptr) {
211 png_destroy_read_struct(&png_ptr, NULL, NULL);
212 return 4; /* out of memory */
213 }
214
215
216 /* we could create a second info struct here (end_info), but it's only
217 * useful if we want to keep pre- and post-IDAT chunk info separated
218 * (mainly for PNG-aware image editors and converters) */
219
220
221 /* setjmp() must be called in every function that calls a PNG-reading
222 * libpng function */
223
224 if (setjmp(png_jmpbuf(png_ptr))) {
225 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
226 return 2;
227 }
228
229
230 png_set_read_fn(png_ptr, NULL, png_read);
231 png_set_error_fn(png_ptr, NULL, png_error_func, png_warn_func);
232
233// png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */
234
235 png_read_info(png_ptr, info_ptr); /* read all PNG info up to image data */
236
237
238 /* alternatively, could make separate calls to png_get_image_width(),
239 * etc., but want bit_depth and png_color_type for later [don't care about
240 * compression_type and filter_type => NULLs] */
241
242 /* OK, that's all we need for now; return happy */
243
244 return 0;
245}
246
247
248/* display_exponent == LUT_exponent * CRT_exponent */

Callers 1

iLoadPngInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected