1 /*
2  * Copyright 2013-2016, Björn Ståhl
3  * License: 3-Clause BSD, see COPYING file in arcan source repository.
4  * Reference: http://arcan-fe.com
5  */
6 
7 #ifndef _HAVE_ARCAN_IMG
8 #define _HAVE_ARCAN_IMG
9 
10 struct arcan_img_meta {
11 	bool compressed;
12 	bool mipmapped;
13 	int pwidth, pheight;
14 	size_t c_size;
15 };
16 
17 void arcan_img_init();
18 
19 /*
20  * Wrapper around the other decode functions in that it tries to
21  * identify (heuristically, experimentally or by the 'hint' inbuf)
22  * the data source and choose decoding routine accordingly.
23  * If *outraw is set, the image data is in a native-compressed format
24  * (ETC1, ...) and needs to be forwarded and treated as such (no postproc.)
25  */
26 arcan_errc arcan_img_decode(const char* hint, char* inbuf, size_t inbuf_sz,
27 	uint32_t** outbuf, size_t* outw, size_t* outh,
28 	struct arcan_img_meta* outm, bool vflip
29 );
30 
31 /*
32  * take the contents of [inbuf] and unpack/[vflip],
33  * then encode as PNG and write to [dst]. [dst] is kept open.
34  */
35 arcan_errc arcan_img_outpng(FILE* dst,
36 	av_pixel* inbuf, size_t inw, size_t inh, bool vflip);
37 
38 /*
39  * make sure that inbuf is propery aligned
40  * and matches the native engine color format.
41  * returns NULL on failure but [inbuf] will always be freed (or re-used)
42  */
43 av_pixel* arcan_img_repack(uint32_t* inbuf, size_t inw, size_t inh);
44 #endif
45