cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumGltfContent::ImageManipulation Class Reference

A collection of utility functions for image manipulation operations. More...

#include <CesiumGltfContent/ImageManipulation.h>

Static Public Member Functions

static void unsafeBlitImage (std::byte *pTarget, size_t targetRowStride, const std::byte *pSource, size_t sourceRowStride, size_t sourceWidth, size_t sourceHeight, size_t bytesPerPixel)
 Directly copies pixels from a source to a target, without validating the provided pointers or ranges.
 
static bool blitImage (CesiumGltf::ImageAsset &target, const PixelRectangle &targetPixels, const CesiumGltf::ImageAsset &source, const PixelRectangle &sourcePixels)
 Copies pixels from a source image to a target image.
 
static std::vector< std::byte > savePng (const CesiumGltf::ImageAsset &image)
 Saves an image to a new byte buffer in PNG format.
 
static void savePng (const CesiumGltf::ImageAsset &image, std::vector< std::byte > &output)
 Saves an image to an existing byte buffer in PNG format.
 

Detailed Description

A collection of utility functions for image manipulation operations.

Definition at line 43 of file ImageManipulation.h.

Member Function Documentation

◆ blitImage()

static bool CesiumGltfContent::ImageManipulation::blitImage ( CesiumGltf::ImageAsset & target,
const PixelRectangle & targetPixels,
const CesiumGltf::ImageAsset & source,
const PixelRectangle & sourcePixels )
static

Copies pixels from a source image to a target image.

If the source and target dimensions are the same, the source pixels are copied exactly into the target. If not, the source image is scaled to fit the target rectangle.

The filtering algorithm for scaling is not specified, but can be assumed to provide reasonably good quality.

The source and target images must have the same number of channels and same bytes per channel. If scaling is required, they must also use exactly 1 byte per channel. If any of these requirements are violated, this function will return false and will not change any target pixels.

The provided rectangles are validated to ensure that they fall within the range of the images. If they do not, this function will return false and will not change any pixels.

Parameters
targetThe image in which to write pixels.
targetPixelsThe pixels to write in the target.
sourceThe image from which to read pixels.
sourcePixelsThe pixels to read from the target.
Returns
True if the source image was blitted successfully into the target, or false if the blit could not be completed due to invalid ranges or incompatible formats.

◆ savePng() [1/2]

static std::vector< std::byte > CesiumGltfContent::ImageManipulation::savePng ( const CesiumGltf::ImageAsset & image)
static

Saves an image to a new byte buffer in PNG format.

Parameters
imageThe image to save.
Returns
The byte buffer containing the image. If the buffer is empty, the image could not be written.

◆ savePng() [2/2]

static void CesiumGltfContent::ImageManipulation::savePng ( const CesiumGltf::ImageAsset & image,
std::vector< std::byte > & output )
static

Saves an image to an existing byte buffer in PNG format.

Parameters
imageThe image to save.
outputThe buffer in which to store the PNG. The image is written to the end of the buffer. If the buffer size is unchanged on return the image could not be written.

◆ unsafeBlitImage()

static void CesiumGltfContent::ImageManipulation::unsafeBlitImage ( std::byte * pTarget,
size_t targetRowStride,
const std::byte * pSource,
size_t sourceRowStride,
size_t sourceWidth,
size_t sourceHeight,
size_t bytesPerPixel )
static

Directly copies pixels from a source to a target, without validating the provided pointers or ranges.

Parameters
pTargetThe pointer at which to start writing pixels.
targetRowStrideThe number of bytes between rows in the target image.
pSourceThe pointer at which to start reading pixels.
sourceRowStrideThe number of bytes between rows in the source image.
sourceWidthThe number of pixels to copy in the horizontal direction.
sourceHeightThe number of pixels to copy in the vertical direction.
bytesPerPixelThe number of bytes used to represent each pixel.

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