MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / encodeWithState

Function encodeWithState

external/lodepng/examples/example_encode.c:72–89  ·  view source on GitHub ↗

Example 3 Save a PNG file to disk using a State, normally needed for more advanced usage. The image argument has width * height RGBA pixels or width * height * 4 bytes */

Source from the content-addressed store, hash-verified

70The image argument has width * height RGBA pixels or width * height * 4 bytes
71*/
72void encodeWithState(const char* filename, const unsigned char* image, unsigned width, unsigned height) {
73 unsigned error;
74 unsigned char* png;
75 size_t pngsize;
76 LodePNGState state;
77
78 lodepng_state_init(&state);
79 /*optionally customize the state*/
80
81 error = lodepng_encode(&png, &pngsize, image, width, height, &state);
82 if(!error) lodepng_save_file(png, pngsize, filename);
83
84 /*if there's an error, display it*/
85 if(error) printf("error %u: %s\n", error, lodepng_error_text(error));
86
87 lodepng_state_cleanup(&state);
88 free(png);
89}
90
91int main(int argc, char *argv[]) {
92 const char* filename = argc > 1 ? argv[1] : "test.png";

Callers

nothing calls this directly

Calls 6

lodepng_state_initFunction · 0.85
lodepng_encodeFunction · 0.85
lodepng_save_fileFunction · 0.85
printfFunction · 0.85
lodepng_error_textFunction · 0.85
lodepng_state_cleanupFunction · 0.85

Tested by

no test coverage detected