2014-12-03 08:39:06 +00:00
|
|
|
/* 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
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
#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
|
|
|
|
|
2023-04-17 09:03:15 +00:00
|
|
|
#include <mgba-util/image.h>
|
|
|
|
|
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);
|
2023-04-17 09:03:15 +00:00
|
|
|
png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height, enum mColorFormat);
|
2023-04-17 11:36:05 +00:00
|
|
|
png_infop PNGWriteHeaderPalette(png_structp png, unsigned width, unsigned height, const uint32_t* palette, unsigned entries);
|
2023-04-17 09:03:15 +00:00
|
|
|
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels, enum mColorFormat);
|
2023-04-17 11:36:05 +00:00
|
|
|
bool PNGWritePixelsPalette(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);
|
2014-07-26 21:06:28 +00:00
|
|
|
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
|