mgba/include/mgba-util/png-io.h

56 lines
2.2 KiB
C
Raw Normal View History

/* Copyright (c) 2013-2014 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2014-07-25 12:44:20 +00:00
#ifndef PNG_IO_H
#define PNG_IO_H
#include <mgba-util/common.h>
2014-07-25 12:44:20 +00:00
2016-12-27 05:01:55 +00:00
CXX_GUARD_START
2014-09-30 08:43:43 +00:00
#ifdef USE_PNG
2017-03-16 19:33:30 +00:00
// png.h defines its own version of restrict which conflicts with mGBA's.
#ifdef restrict
#undef restrict
#endif
2014-07-25 12:44:20 +00:00
#include <png.h>
struct VFile;
2014-07-26 20:20:29 +00:00
enum {
PNG_HEADER_BYTES = 8
};
2014-07-25 12:44:20 +00:00
png_structp PNGWriteOpen(struct VFile* source);
png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height);
png_infop PNGWriteHeaderA(png_structp png, unsigned width, unsigned height);
2017-02-03 00:33:27 +00:00
png_infop PNGWriteHeader8(png_structp png, unsigned width, unsigned height);
bool PNGWritePalette(png_structp png, png_infop info, const uint32_t* palette, unsigned entries);
2015-09-03 07:28:16 +00:00
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
bool PNGWritePixelsA(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
2017-02-03 00:33:27 +00:00
bool PNGWritePixels8(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
2014-07-25 12:44:20 +00:00
bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
void PNGWriteClose(png_structp png, png_infop info);
2014-07-26 20:20:29 +00:00
typedef int (*ChunkHandler)(png_structp, png_unknown_chunkp);
bool isPNG(struct VFile* source);
png_structp PNGReadOpen(struct VFile* source, unsigned offset);
bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
bool PNGReadHeader(png_structp png, png_infop info);
bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
2018-09-13 02:27:23 +00:00
bool PNGReadPixelsA(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
bool PNGReadPixels8(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
2014-07-26 20:20:29 +00:00
bool PNGIgnorePixels(png_structp png, png_infop info);
bool PNGReadFooter(png_structp png, png_infop end);
void PNGReadClose(png_structp png, png_infop info, png_infop end);
2014-07-25 12:44:20 +00:00
#endif
2014-09-30 08:43:43 +00:00
2016-12-27 05:01:55 +00:00
CXX_GUARD_END
2014-09-30 08:43:43 +00:00
#endif