QtCraft API C++ classes QML types Handbook

QcTexturePackLoader Namespace

Reads a texture pack folder (decision E-297) and checks everything in it at the system boundary (decision E-298): the manifest, file names (only textures/<namespace>/<name>.png|json, no links, no hidden files, so nothing outside the folder is read), the number and size of files, PNG signature, size and resolution, damaged images and a budget for decoded image memory. More...

Header: #include <clientcore/texturepacks/QcTexturePackLoader.h>

Classes

struct Image
struct Limits

Functions

std::expected<QcTexturePack, QcTexturePackProblem> load(const QString &directory, const QString &id, QcTexturePack::Origin origin, const QcTexturePackLoader::Limits &limits = {})
std::expected<QcTexturePackLoader::Image, QcTexturePackProblem> readImage(const QByteArray &bytes, int resolution, const QcTexturePackLoader::Limits &limits = {})
std::expected<QcTexturePackManifest, QcTexturePackProblem> readManifest(const QString &directory)
std::expected<QImage, QcTexturePackProblem> readPreview(const QString &directory, const QcTexturePackManifest &manifest, const QcTexturePackLoader::Limits &limits = {})

Detailed Description

A bad file is skipped with a problem and its texture falls back to the next pack; only a missing or invalid manifest makes the whole pack unusable.

Classes

class Image

A checked PNG texture: the first frame at the pack's resolution and how many frames the file had, the frames after the first at the same size (a vertical strip animates, decision E-878). More...

class Limits

Limits a pack must keep, checked while loading. More...

Function Documentation

std::expected<QcTexturePack, QcTexturePackProblem> QcTexturePackLoader::load(const QString &directory, const QString &id, QcTexturePack::Origin origin, const QcTexturePackLoader::Limits &limits = {})

Returns the pack in directory with id and origin, checked against limits; the error when its manifest is missing or invalid.

std::expected<QcTexturePackLoader::Image, QcTexturePackProblem> QcTexturePackLoader::readImage(const QByteArray &bytes, int resolution, const QcTexturePackLoader::Limits &limits = {})

Returns the image of one PNG file's bytes, checked against the pack's resolution and limits.

std::expected<QcTexturePackManifest, QcTexturePackProblem> QcTexturePackLoader::readManifest(const QString &directory)

Returns the manifest of the pack folder directory alone (for listing packs without loading their images).

std::expected<QImage, QcTexturePackProblem> QcTexturePackLoader::readPreview(const QString &directory, const QcTexturePackManifest &manifest, const QcTexturePackLoader::Limits &limits = {})

Returns the preview image manifest names in directory (at most 512 x 512 pixels, within limits); a null image when it names none.