#pragma once12#include <cstdint>34#include "Common/BitSet.h"56// *image_data_ptr should be deleted with free()7// return value of 1 == success.8int pngLoad(const char *file, int *pwidth,9int *pheight, unsigned char **image_data_ptr);1011int pngLoadPtr(const unsigned char *input_ptr, size_t input_len, int *pwidth,12int *pheight, unsigned char **image_data_ptr);1314// PNG peeker - just read the start of a PNG straight into this struct, in order to15// look at basic parameters like width and height. Note that while PNG is a chunk-based16// format, the IHDR chunk is REQUIRED to be the first one, so this will work.17// Does not handle Apple's weirdo extension CgBI. http://iphonedevwiki.net/index.php/CgBI_file_format18// That should not be an issue.19struct PNGHeaderPeek {20uint32_t magic;21uint32_t ignore0;22uint32_t ignore1;23uint32_t ihdrTag;24uint32_t be_width; // big endian25uint32_t be_height;26uint8_t bitDepth; // bits per channel, can be 1, 2, 4, 8, 1627uint8_t colorType; // really, pixel format. 0 = grayscale, 2 = rgb, 3 = palette index, 4 = gray+alpha, 6 = rgba2829bool IsValidPNGHeader() const;30int Width() const { return swap32(be_width); }31int Height() const { return swap32(be_height); }32};333435