all repos — mgba @ cc2362aea9c63bf914972bbeda8b2bae114da4f9

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 PNGWriteHeaderA(png_structp png, unsigned width, unsigned height);
30png_infop PNGWriteHeader8(png_structp png, unsigned width, unsigned height);
31bool PNGWritePalette(png_structp png, png_infop info, const uint32_t* palette, unsigned entries);
32bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
33bool PNGWritePixelsA(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
34bool PNGWritePixels8(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
35bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
36void PNGWriteClose(png_structp png, png_infop info);
37
38typedef int (*ChunkHandler)(png_structp, png_unknown_chunkp);
39
40bool isPNG(struct VFile* source);
41png_structp PNGReadOpen(struct VFile* source, unsigned offset);
42bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
43bool PNGReadHeader(png_structp png, png_infop info);
44bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
45bool PNGIgnorePixels(png_structp png, png_infop info);
46bool PNGReadFooter(png_structp png, png_infop end);
47void PNGReadClose(png_structp png, png_infop info, png_infop end);
48
49#endif
50
51CXX_GUARD_END
52
53#endif