CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/Data/Format/ZIMLoad.h
Views: 1401
#pragma once12#include <cstdint>34// LoadZIM's responsibility:5// * Parse the ZIM format6// * Extract all mip levels so they can be uploaded to GPU7//8// * NOT convert formats to anything, except converting ETC1 to RGBA8888 when running on the PC910// ZIM format:11// 4 byte ZIMG12// 4 byte width13// 4 byte height14// 4 byte flags15// Uncompressed or ZLibbed data. If multiple mips, zlibbed separately.1617// Defined flags:1819enum {20ZIM_RGBA8888 = 0, // Assumed format if no other format is set21ZIM_RGBA4444 = 1, // GL_UNSIGNED_SHORT_4_4_4_422ZIM_RGB565 = 2, // GL_UNSIGNED_SHORT_5_6_523// There's space for plenty more formats.24ZIM_FORMAT_MASK = 15,25ZIM_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.26ZIM_GEN_MIPS = 32, // If set, the caller is advised to automatically generate mips. (maybe later, the ZIM lib will generate the mips for you).27ZIM_DITHER = 64, // If set, dithers during save if color reduction is necessary.28ZIM_CLAMP = 128, // Texture should default to clamp instead of wrap.29ZIM_ZLIB_COMPRESSED = 256,30ZIM_ETC1_LOW = 512,31ZIM_ETC1_MEDIUM = 1024,32ZIM_ETC1_HIGH = 0, // default33ZIM_ETC1_DITHER = 2048,34ZIM_ZSTD_COMPRESSED = 4096,35};3637// ZIM will only ever support up to 12 levels (4096x4096 max).38enum {39ZIM_MAX_MIP_LEVELS = 12,40};4142// Delete the returned pointer using free()43// Watch out! If the image has mipmaps, multiple values will be written44// to width, height, and image, as if they were arrays, up to 12 (max texture size is 4096 which is 2^12).45int LoadZIM(const char *filename, int *width, int *height, int *flags, uint8_t **image);46int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8_t **image);474849