cesium-native  0.41.0
CesiumGltf::ImageAsset Struct Referencefinal

A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GPU compression format. More...

#include <CesiumGltf/ImageAsset.h>

Inheritance diagram for CesiumGltf::ImageAsset:
CesiumUtility::SharedAsset< ImageAsset > CesiumUtility::ExtensibleObject

Public Member Functions

int64_t getSizeBytes () const
 Gets the size of this asset, in bytes. More...
 
- Public Member Functions inherited from CesiumUtility::SharedAsset< ImageAsset >
void addReference () const noexcept
 Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this method directly.
 
void releaseReference () const noexcept
 Removes a counted reference from this object. When the last reference is removed, this method will delete this instance. Use CesiumUtility::IntrusivePointer instead of calling this method directly.
 
const IDepotOwningAsset< ImageAsset > * getDepot () const
 Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset depot.
 
IDepotOwningAsset< ImageAsset > * getDepot ()
 Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset depot.
 
- Public Member Functions inherited from CesiumUtility::ExtensibleObject
template<typename T >
bool hasExtension () const noexcept
 Checks if an extension exists given its static type. More...
 
template<typename T >
const T * getExtension () const noexcept
 Gets an extension given its static type. More...
 
template<typename T >
T * getExtension () noexcept
 Gets an extension given its static type. More...
 
const JsonValuegetGenericExtension (const std::string &extensionName) const noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue. More...
 
JsonValuegetGenericExtension (const std::string &extensionName) noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue. More...
 
template<typename T , typename... ConstructorArgumentTypes>
T & addExtension (ConstructorArgumentTypes &&... constructorArguments)
 Adds a statically-typed extension to this object. More...
 
template<typename T >
void removeExtension ()
 Removes a statically-typed extension from this object. More...
 

Public Attributes

int32_t width = 0
 The width of the image in pixels.
 
int32_t height = 0
 The height of the image in pixels.
 
int32_t channels = 4
 The number of channels per pixel.
 
int32_t bytesPerChannel = 1
 The number of bytes per channel.
 
GpuCompressedPixelFormat compressedPixelFormat
 The gpu compressed pixel format for this image or NONE if it is not compressed. More...
 
std::vector< ImageAssetMipPositionmipPositions
 The offset of each mip in the pixel data. More...
 
std::vector< std::byte > pixelData
 The pixel data. More...
 
int64_t sizeBytes = -1
 The effective size of this image, in bytes, for estimating resource usage for caching purposes. More...
 
- Public Attributes inherited from CesiumUtility::ExtensibleObject
std::unordered_map< std::string, std::any > extensions
 The extensions attached to this object. More...
 
JsonValue::Object extras
 Application-specific data. More...
 
JsonValue::Object unknownProperties
 Unknown properties that exist on this object but do not have any representation in the statically-typed classes. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CesiumUtility::SharedAsset< ImageAsset >
 SharedAsset (const SharedAsset &rhs)
 
 SharedAsset (SharedAsset &&rhs)
 
SharedAssetoperator= (const SharedAsset &rhs)
 
SharedAssetoperator= (SharedAsset &&rhs)
 

Detailed Description

A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GPU compression format.

Definition at line 33 of file ImageAsset.h.

Member Function Documentation

◆ getSizeBytes()

int64_t CesiumGltf::ImageAsset::getSizeBytes ( ) const
inline

Gets the size of this asset, in bytes.

If sizeBytes is greater than or equal to zero, it is returned. Otherwise, the size of the pixelData array is returned.

Definition at line 122 of file ImageAsset.h.

Member Data Documentation

◆ compressedPixelFormat

GpuCompressedPixelFormat CesiumGltf::ImageAsset::compressedPixelFormat
Initial value:
=
GpuCompressedPixelFormat::NONE

The gpu compressed pixel format for this image or NONE if it is not compressed.

Definition at line 59 of file ImageAsset.h.

◆ mipPositions

std::vector<ImageAssetMipPosition> CesiumGltf::ImageAsset::mipPositions

The offset of each mip in the pixel data.

A list of the positions of each mip's data within the overall pixel buffer. The first element will be the full image, the second will be the second biggest and etc. If this is empty, assume the entire buffer is a single image, the mip map will need to be generated on the client in this case.

Definition at line 70 of file ImageAsset.h.

◆ pixelData

std::vector<std::byte> CesiumGltf::ImageAsset::pixelData

The pixel data.

This will be the raw pixel data when compressedPixelFormat is std::nullopt. Otherwise, this buffer will store the compressed pixel data in the specified format.

If mipPositions is not empty, this buffer will contains multiple mips back-to-back.

When this is an uncompressed texture: -The pixel data is consistent with the stb image library.

-For a correctly-formed image, the size of the array will be width * height * channels * bytesPerChannel bytes. There is no padding between rows or columns of the image, regardless of format.

-The channels and their meaning are as follows:

Number of Channels Channel Order and Meaning
1 grey
2 grey, alpha
3 red, green, blue
4 red, green, blue, alpha

Definition at line 99 of file ImageAsset.h.

◆ sizeBytes

int64_t CesiumGltf::ImageAsset::sizeBytes = -1

The effective size of this image, in bytes, for estimating resource usage for caching purposes.

When this value is less than zero (the default), the size of this image should be assumed to equal the size of the pixelData array. When it is greater than or equal to zero, the specified size should be used instead. For example, the overridden size may account for:

  • The pixelData being cleared during the load process in order to save memory.
  • The cost of any renderer resources (e.g., GPU textures) created for this image.

Definition at line 114 of file ImageAsset.h.


The documentation for this struct was generated from the following file: