1 | // MIT License |
2 | |
3 | // Copyright (c) 2021 Vadim Grigoruk @nesbox // grigoruk@gmail.com |
4 | |
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
6 | // of this software and associated documentation files (the "Software"), to deal |
7 | // in the Software without restriction, including without limitation the rights |
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 | // copies of the Software, and to permit persons to whom the Software is |
10 | // furnished to do so, subject to the following conditions: |
11 | |
12 | // The above copyright notice and this permission notice shall be included in all |
13 | // copies or substantial portions of the Software. |
14 | |
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
21 | // SOFTWARE. |
22 | |
23 | #pragma once |
24 | |
25 | #include <tic80_types.h> |
26 | |
27 | typedef struct |
28 | { |
29 | u8* data; |
30 | s32 size; |
31 | } png_buffer; |
32 | |
33 | typedef union |
34 | { |
35 | struct |
36 | { |
37 | u8 r; |
38 | u8 g; |
39 | u8 b; |
40 | u8 a; |
41 | }; |
42 | |
43 | u8 data[4]; |
44 | |
45 | u32 value; |
46 | } png_rgba; |
47 | |
48 | typedef struct |
49 | { |
50 | s32 width; |
51 | s32 height; |
52 | |
53 | union |
54 | { |
55 | png_rgba* pixels; |
56 | u32* values; |
57 | u8* data; |
58 | }; |
59 | } png_img; |
60 | |
61 | png_buffer png_create(s32 size); |
62 | |
63 | png_img png_read(png_buffer buf); |
64 | png_buffer png_write(png_img src); |
65 | |
66 | png_buffer png_encode(png_buffer cover, png_buffer cart); |
67 | png_buffer png_decode(png_buffer cover); |
68 | |