A collection of utility functions for image manipulation operations.
More...
#include <CesiumGltfContent/ImageManipulation.h>
|
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.
|
|
A collection of utility functions for image manipulation operations.
Definition at line 43 of file ImageManipulation.h.
◆ blitImage()
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
-
target | The image in which to write pixels. |
targetPixels | The pixels to write in the target. |
source | The image from which to read pixels. |
sourcePixels | The 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
-
- 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
-
image | The image to save. |
output | The 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
-
pTarget | The pointer at which to start writing pixels. |
targetRowStride | The number of bytes between rows in the target image. |
pSource | The pointer at which to start reading pixels. |
sourceRowStride | The number of bytes between rows in the source image. |
sourceWidth | The number of pixels to copy in the horizontal direction. |
sourceHeight | The number of pixels to copy in the vertical direction. |
bytesPerPixel | The number of bytes used to represent each pixel. |
The documentation for this class was generated from the following file:
- /home/runner/work/cesium-native/cesium-native/CesiumGltfContent/include/CesiumGltfContent/ImageManipulation.h