include/mgba-util/png-io.h (view raw)
1/* Copyright (c) 2013-2014 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef PNG_IO_H
7#define PNG_IO_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#ifdef USE_PNG
14
15#include <png.h>
16
17struct VFile;
18
19enum {
20 PNG_HEADER_BYTES = 8
21};
22
23png_structp PNGWriteOpen(struct VFile* source);
24png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height);
25png_infop PNGWriteHeader8(png_structp png, unsigned width, unsigned height);
26bool PNGWritePalette(png_structp png, png_infop info, const uint32_t* palette, unsigned entries);
27bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
28bool PNGWritePixels8(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
29bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
30void PNGWriteClose(png_structp png, png_infop info);
31
32typedef int (*ChunkHandler)(png_structp, png_unknown_chunkp);
33
34bool isPNG(struct VFile* source);
35png_structp PNGReadOpen(struct VFile* source, unsigned offset);
36bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
37bool PNGReadHeader(png_structp png, png_infop info);
38bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
39bool PNGIgnorePixels(png_structp png, png_infop info);
40bool PNGReadFooter(png_structp png, png_infop end);
41void PNGReadClose(png_structp png, png_infop info, png_infop end);
42
43#endif
44
45CXX_GUARD_END
46
47#endif