cesium-native 0.43.0
Loading...
Searching...
No Matches
ImageAsset.h
1#pragma once
2
3#include "CesiumGltf/Ktx2TranscodeTargets.h"
4#include "CesiumGltf/Library.h"
5#include "CesiumUtility/SharedAsset.h"
6
7#include <cstddef>
8#include <cstdint>
9#include <optional>
10#include <vector>
11
12namespace CesiumGltf {
13
17struct CESIUMGLTF_API ImageAssetMipPosition {
21 size_t byteOffset;
22
26 size_t byteSize;
27};
28
33struct CESIUMGLTF_API ImageAsset final
34 : public CesiumUtility::SharedAsset<ImageAsset> {
38 int32_t width = 0;
39
43 int32_t height = 0;
44
48 int32_t channels = 4;
49
53 int32_t bytesPerChannel = 1;
54
59 GpuCompressedPixelFormat compressedPixelFormat =
60 GpuCompressedPixelFormat::NONE;
61
70 std::vector<ImageAssetMipPosition> mipPositions;
71
99 std::vector<std::byte> pixelData;
100
114 int64_t sizeBytes = -1;
115
119 ImageAsset() = default;
120
127 int64_t getSizeBytes() const {
128 return this->sizeBytes >= 0 ? this->sizeBytes
129 : static_cast<int64_t>(this->pixelData.size());
130 }
131};
132} // namespace CesiumGltf
An asset that is potentially shared between multiple objects, such as an image shared between multipl...
Definition SharedAsset.h:52
Classes for working with glTF models.
GpuCompressedPixelFormat
Supported GPU compressed pixel formats.
The byte range within a buffer where this mip exists.
Definition ImageAsset.h:17
size_t byteOffset
The byte index where this mip begins.
Definition ImageAsset.h:21
size_t byteSize
The size in bytes of this mip.
Definition ImageAsset.h:26
A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GP...
Definition ImageAsset.h:34
std::vector< ImageAssetMipPosition > mipPositions
The offset of each mip in the pixel data.
Definition ImageAsset.h:70
ImageAsset()=default
Constructs an empty image asset.
int64_t getSizeBytes() const
Gets the size of this asset, in bytes.
Definition ImageAsset.h:127
std::vector< std::byte > pixelData
The pixel data.
Definition ImageAsset.h:99