cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumGltfReader::ImageDecoder Class Reference

Contains methods for reading and manipulating images. More...

#include <CesiumGltfReader/ImageDecoder.h>

Static Public Member Functions

static ImageReaderResult readImage (const std::span< const std::byte > &data, const CesiumGltf::Ktx2TranscodeTargets &ktx2TranscodeTargets)
 Reads an image from a buffer.
 
static std::optional< std::string > generateMipMaps (CesiumGltf::ImageAsset &image)
 Generate mipmaps for this image.
 
static bool unsafeResize (const std::byte *pInputPixels, int32_t inputWidth, int32_t inputHeight, int32_t inputStrideBytes, std::byte *pOutputPixels, int32_t outputWidth, int32_t outputHeight, int32_t outputStrideBytes, int32_t channels)
 Resize an image, without validating the provided pointers or ranges.
 

Detailed Description

Contains methods for reading and manipulating images.

Definition at line 41 of file ImageDecoder.h.

Member Function Documentation

◆ generateMipMaps()

static std::optional< std::string > CesiumGltfReader::ImageDecoder::generateMipMaps ( CesiumGltf::ImageAsset & image)
static

Generate mipmaps for this image.

Does nothing if mipmaps already exist or the compressedPixelFormat is not GpuCompressedPixelFormat::NONE.

Parameters
imageThe image to generate mipmaps for. *
Returns
A string describing the error, if unable to generate mipmaps.

◆ readImage()

static ImageReaderResult CesiumGltfReader::ImageDecoder::readImage ( const std::span< const std::byte > & data,
const CesiumGltf::Ktx2TranscodeTargets & ktx2TranscodeTargets )
static

Reads an image from a buffer.

The stb_image library is used to decode images in JPG, PNG, TGA, BMP, PSD, GIF, HDR, or PIC format.

Parameters
dataThe buffer from which to read the image.
ktx2TranscodeTargetsThe compression format to transcode KTX v2 textures into. If this is std::nullopt, KTX v2 textures will be fully decompressed into raw pixels.
Returns
The result of reading the image.

◆ unsafeResize()

static bool CesiumGltfReader::ImageDecoder::unsafeResize ( const std::byte * pInputPixels,
int32_t inputWidth,
int32_t inputHeight,
int32_t inputStrideBytes,
std::byte * pOutputPixels,
int32_t outputWidth,
int32_t outputHeight,
int32_t outputStrideBytes,
int32_t channels )
static

Resize an image, without validating the provided pointers or ranges.

Parameters
pInputPixelsThe input image.
inputWidthThe width of the input image, in pixels.
inputHeightThe height of the input image, in pixels.
inputStrideBytesThe stride of the input image, in bytes. Stride is the number of bytes between successive rows.
pOutputPixelsThe buffer into which to write the output image.
outputWidthThe width of the output image, in pixels.
outputHeightThe height of the otuput image, in pixels.
outputStrideBytesThe stride of the output image, in bytes. Stride is the number of bytes between successive rows.
channelsThe number of channels in both the input and output images.
Returns
True if the resize succeeded, false if it failed.

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