all repos — mgba @ 15b4df3b2b021e9fa08f179316c4945ea0125e7a

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// png.h defines its own version of restrict which conflicts with mGBA's.
16#ifdef restrict
17#undef restrict
18#endif
19#include <png.h>
20
21struct VFile;
22
23enum {
24	PNG_HEADER_BYTES = 8
25};
26
27png_structp PNGWriteOpen(struct VFile* source);
28png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height);
29png_infop PNGWriteHeader8(png_structp png, unsigned width, unsigned height);
30bool PNGWritePalette(png_structp png, png_infop info, const uint32_t* palette, unsigned entries);
31bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
32bool PNGWritePixels8(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
33bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
34void PNGWriteClose(png_structp png, png_infop info);
35
36typedef int (*ChunkHandler)(png_structp, png_unknown_chunkp);
37
38bool isPNG(struct VFile* source);
39png_structp PNGReadOpen(struct VFile* source, unsigned offset);
40bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
41bool PNGReadHeader(png_structp png, png_infop info);
42bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
43bool PNGIgnorePixels(png_structp png, png_infop info);
44bool PNGReadFooter(png_structp png, png_infop end);
45void PNGReadClose(png_structp png, png_infop info, png_infop end);
46
47#endif
48
49CXX_GUARD_END
50
51#endif