CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/Data/Format/PNGLoad.h
Views: 1401
1
#pragma once
2
3
#include <cstdint>
4
5
#include "Common/BitSet.h"
6
7
// *image_data_ptr should be deleted with free()
8
// return value of 1 == success.
9
int pngLoad(const char *file, int *pwidth,
10
int *pheight, unsigned char **image_data_ptr);
11
12
int pngLoadPtr(const unsigned char *input_ptr, size_t input_len, int *pwidth,
13
int *pheight, unsigned char **image_data_ptr);
14
15
// PNG peeker - just read the start of a PNG straight into this struct, in order to
16
// look at basic parameters like width and height. Note that while PNG is a chunk-based
17
// format, the IHDR chunk is REQUIRED to be the first one, so this will work.
18
// Does not handle Apple's weirdo extension CgBI. http://iphonedevwiki.net/index.php/CgBI_file_format
19
// That should not be an issue.
20
struct PNGHeaderPeek {
21
uint32_t magic;
22
uint32_t ignore0;
23
uint32_t ignore1;
24
uint32_t ihdrTag;
25
uint32_t be_width; // big endian
26
uint32_t be_height;
27
uint8_t bitDepth; // bits per channel, can be 1, 2, 4, 8, 16
28
uint8_t colorType; // really, pixel format. 0 = grayscale, 2 = rgb, 3 = palette index, 4 = gray+alpha, 6 = rgba
29
30
bool IsValidPNGHeader() const;
31
int Width() const { return swap32(be_width); }
32
int Height() const { return swap32(be_height); }
33
};
34
35