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/ZIMLoad.h
Views: 1401
1
#pragma once
2
3
#include <cstdint>
4
5
// LoadZIM's responsibility:
6
// * Parse the ZIM format
7
// * Extract all mip levels so they can be uploaded to GPU
8
//
9
// * NOT convert formats to anything, except converting ETC1 to RGBA8888 when running on the PC
10
11
// ZIM format:
12
// 4 byte ZIMG
13
// 4 byte width
14
// 4 byte height
15
// 4 byte flags
16
// Uncompressed or ZLibbed data. If multiple mips, zlibbed separately.
17
18
// Defined flags:
19
20
enum {
21
ZIM_RGBA8888 = 0, // Assumed format if no other format is set
22
ZIM_RGBA4444 = 1, // GL_UNSIGNED_SHORT_4_4_4_4
23
ZIM_RGB565 = 2, // GL_UNSIGNED_SHORT_5_6_5
24
// There's space for plenty more formats.
25
ZIM_FORMAT_MASK = 15,
26
ZIM_HAS_MIPS = 16, // If set, assumes that a full mip chain is present. Mips are zlib-compressed individually and stored in sequence. Always half sized.
27
ZIM_GEN_MIPS = 32, // If set, the caller is advised to automatically generate mips. (maybe later, the ZIM lib will generate the mips for you).
28
ZIM_DITHER = 64, // If set, dithers during save if color reduction is necessary.
29
ZIM_CLAMP = 128, // Texture should default to clamp instead of wrap.
30
ZIM_ZLIB_COMPRESSED = 256,
31
ZIM_ETC1_LOW = 512,
32
ZIM_ETC1_MEDIUM = 1024,
33
ZIM_ETC1_HIGH = 0, // default
34
ZIM_ETC1_DITHER = 2048,
35
ZIM_ZSTD_COMPRESSED = 4096,
36
};
37
38
// ZIM will only ever support up to 12 levels (4096x4096 max).
39
enum {
40
ZIM_MAX_MIP_LEVELS = 12,
41
};
42
43
// Delete the returned pointer using free()
44
// Watch out! If the image has mipmaps, multiple values will be written
45
// to width, height, and image, as if they were arrays, up to 12 (max texture size is 4096 which is 2^12).
46
int LoadZIM(const char *filename, int *width, int *height, int *flags, uint8_t **image);
47
int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8_t **image);
48
49