all repos — mgba @ 2f14f58911539fd67228c9113665c5df26061154

mGBA Game Boy Advance Emulator

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);
25bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
26bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
27void PNGWriteClose(png_structp png, png_infop info);
28
29typedef int (*ChunkHandler)(png_structp, png_unknown_chunkp);
30
31bool isPNG(struct VFile* source);
32png_structp PNGReadOpen(struct VFile* source, unsigned offset);
33bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
34bool PNGReadHeader(png_structp png, png_infop info);
35bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
36bool PNGIgnorePixels(png_structp png, png_infop info);
37bool PNGReadFooter(png_structp png, png_infop end);
38void PNGReadClose(png_structp png, png_infop info, png_infop end);
39
40#endif
41
42CXX_GUARD_END
43
44#endif