cesium-native 0.50.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 <vector>
10
11namespace CesiumGltf {
12
16struct CESIUMGLTF_API ImageAssetMipPosition {
20 size_t byteOffset;
21
25 size_t byteSize;
26};
27
32struct CESIUMGLTF_API ImageAsset final
33 : public CesiumUtility::SharedAsset<ImageAsset> {
37 int32_t width = 0;
38
42 int32_t height = 0;
43
47 int32_t channels = 4;
48
52 int32_t bytesPerChannel = 1;
53
60
69 std::vector<ImageAssetMipPosition> mipPositions;
70
98 std::vector<std::byte> pixelData;
99
113 int64_t sizeBytes = -1;
114
118 ImageAsset() = default;
119
136 int32_t newChannels,
137 std::byte defaultValue = std::byte{0});
138
145 int64_t getSizeBytes() const {
146 return this->sizeBytes >= 0 ? this->sizeBytes
147 : static_cast<int64_t>(this->pixelData.size());
148 }
149};
150} // 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:16
size_t byteOffset
The byte index where this mip begins.
Definition ImageAsset.h:20
size_t byteSize
The size in bytes of this mip.
Definition ImageAsset.h:25
int64_t sizeBytes
The effective size of this image, in bytes, for estimating resource usage for caching purposes.
Definition ImageAsset.h:113
int32_t bytesPerChannel
The number of bytes per channel.
Definition ImageAsset.h:52
int32_t height
The height of the image in pixels.
Definition ImageAsset.h:42
std::vector< ImageAssetMipPosition > mipPositions
The offset of each mip in the pixel data.
Definition ImageAsset.h:69
ImageAsset()=default
Constructs an empty image asset.
int64_t getSizeBytes() const
Gets the size of this asset, in bytes.
Definition ImageAsset.h:145
int32_t width
The width of the image in pixels.
Definition ImageAsset.h:37
int32_t channels
The number of channels per pixel.
Definition ImageAsset.h:47
void changeNumberOfChannels(int32_t newChannels, std::byte defaultValue=std::byte{0})
Converts this image to the given number of channels.
GpuCompressedPixelFormat compressedPixelFormat
The gpu compressed pixel format for this image or NONE if it is not compressed.
Definition ImageAsset.h:58
std::vector< std::byte > pixelData
The pixel data.
Definition ImageAsset.h:98