cesium-native  0.41.0
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 
12 namespace CesiumGltf {
13 
17 struct CESIUMGLTF_API ImageAssetMipPosition {
21  size_t byteOffset;
22 
26  size_t byteSize;
27 };
28 
33 struct 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 
122  int64_t getSizeBytes() const {
123  return this->sizeBytes >= 0 ? this->sizeBytes : this->pixelData.size();
124  }
125 };
126 } // 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.
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
int64_t getSizeBytes() const
Gets the size of this asset, in bytes.
Definition: ImageAsset.h:122
std::vector< std::byte > pixelData
The pixel data.
Definition: ImageAsset.h:99