Plasma Engine  2.0
Loading...
Searching...
No Matches
plImageUtils Class Reference

Classes

struct  MipMapOptions
 Mip map generation options. More...
 

Static Public Member Functions

static void ComputeImageDifferenceABS (const plImageView &imageA, const plImageView &imageB, plImage &out_difference)
 Returns the image with the difference (absolute values) between ImageA and ImageB.
 
static void ComputeImageDifferenceABSRelaxed (const plImageView &imageA, const plImageView &imageB, plImage &out_difference)
 Same as ComputeImageDifferenceABS, but for every pixel in imageA, the minimum diff in imageB is searched in a 1-pixel radius, allowing pixels in B to shift slightly without incurring a difference.
 
static plUInt32 ComputeMeanSquareError (const plImageView &differenceImage, plUInt8 uiBlockSize, plUInt32 uiOffsetx, plUInt32 uiOffsety)
 Computes the mean square error for the block at (offsetx, offsety) to (offsetx + uiBlockSize, offsety + uiBlockSize). DifferenceImage is expected to be an image that represents the difference between two images.
 
static plUInt32 ComputeMeanSquareError (const plImageView &differenceImage, plUInt8 uiBlockSize)
 Computes the mean square error of DifferenceImage, by computing the MSE for blocks of uiBlockSize and returning the maximum MSE that was found.
 
static void Normalize (plImage &ref_image)
 Rescales pixel values to use the full value range by scaling from [min, max] to [0, 255]. Computes combined min/max for RGB and separate min/max for alpha.
 
static void Normalize (plImage &ref_image, plUInt8 &ref_uiMinRgb, plUInt8 &ref_uiMaxRgb, plUInt8 &ref_uiMinAlpha, plUInt8 &ref_uiMaxAlpha)
 
static void ExtractAlphaChannel (const plImageView &inputImage, plImage &ref_outputImage)
 Extracts the alpha channel from 8bpp 4 channel images into a 8bpp single channel image.
 
static void CropImage (const plImageView &input, const plVec2I32 &vOffset, const plSizeU32 &newsize, plImage &ref_output)
 Returns the sub-image of input that starts at offset and has the size newsize.
 
static void RotateSubImage180 (plImage &ref_image, plUInt32 uiMipLevel=0, plUInt32 uiFace=0, plUInt32 uiArrayIndex=0)
 rotates a sub image by 180 degrees in place. Only works with uncompressed images.
 
static plResult Copy (const plImageView &srcImg, const plRectU32 &srcRect, plImage &ref_dstImg, const plVec3U32 &vDstOffset, plUInt32 uiDstMipLevel=0, plUInt32 uiDstFace=0, plUInt32 uiDstArrayIndex=0)
 Copies the source image into the destination image at the specified location.
 
static plResult ExtractLowerMipChain (const plImageView &src, plImage &ref_dst, plUInt32 uiNumMips)
 Copies the lower uiNumMips data of a 2D image into another one.
 
static plResult Scale (const plImageView &source, plImage &ref_target, plUInt32 uiWidth, plUInt32 uiHeight, const plImageFilter *pFilter=nullptr, plImageAddressMode::Enum addressModeU=plImageAddressMode::Clamp, plImageAddressMode::Enum addressModeV=plImageAddressMode::Clamp, const plColor &borderColor=plColor::Black)
 Scales the image.
 
static plResult Scale3D (const plImageView &source, plImage &ref_target, plUInt32 uiWidth, plUInt32 uiHeight, plUInt32 uiDepth, const plImageFilter *pFilter=nullptr, plImageAddressMode::Enum addressModeU=plImageAddressMode::Clamp, plImageAddressMode::Enum addressModeV=plImageAddressMode::Clamp, plImageAddressMode::Enum addressModeW=plImageAddressMode::Clamp, const plColor &borderColor=plColor::Black)
 Scales the image.
 
static void GenerateMipMaps (const plImageView &source, plImage &ref_target, const MipMapOptions &options)
 Genererates the mip maps for the image. The input texture must be in plImageFormat::R32_G32_B32_A32_FLOAT.
 
static void ReconstructNormalZ (plImage &ref_source)
 Assumes that the Red and Green components of an image contain XY of an unit length normal and reconstructs the Z component into B.
 
static void RenormalizeNormalMap (plImage &ref_image)
 Renormalizes a normal map to unit length.
 
static void AdjustRoughness (plImage &ref_roughnessMap, const plImageView &normalMap)
 Adjust the roughness in lower mip levels so it maintains the same look from all distances.
 
static void ChangeExposure (plImage &ref_image, float fBias)
 Changes the exposure of an HDR image by 2^bias.
 
static plResult CreateCubemapFromSingleFile (plImage &ref_dstImg, const plImageView &srcImg)
 Creates a cubemap from srcImg and stores it in dstImg.
 
static plResult CreateCubemapFrom6Files (plImage &ref_dstImg, const plImageView *pSourceImages)
 Copies the 6 given source images to the faces of dstImg.
 
static plResult CreateVolumeTextureFromSingleFile (plImage &ref_dstImg, const plImageView &srcImg)
 
static plUInt32 GetSampleIndex (plUInt32 uiNumTexels, plInt32 iIndex, plImageAddressMode::Enum addressMode, bool &out_bUseBorderColor)
 
static plColor NearestSample (const plImageView &image, plImageAddressMode::Enum addressMode, plVec2 vUv)
 Samples the image at the given UV coordinates with nearest filtering.
 
static plColor NearestSample (const plColor *pPixelPointer, plUInt32 uiWidth, plUInt32 uiHeight, plImageAddressMode::Enum addressMode, plVec2 vUv)
 Samples the image at the given UV coordinates with nearest filtering.
 
static plColor BilinearSample (const plImageView &image, plImageAddressMode::Enum addressMode, plVec2 vUv)
 Samples the image at the given UV coordinates with bilinear filtering.
 
static plColor BilinearSample (const plColor *pPixelPointer, plUInt32 uiWidth, plUInt32 uiHeight, plImageAddressMode::Enum addressMode, plVec2 vUv)
 Samples the image at the given UV coordinates with bilinear filtering.
 
static plResult CopyChannel (plImage &ref_dstImg, plUInt8 uiDstChannelIdx, const plImage &srcImg, plUInt8 uiSrcChannelIdx)
 Copies channel 0, 1, 2 or 3 from srcImg into dstImg.
 
static void EmbedImageData (plStringBuilder &out_sHtml, const plImage &image)
 Embeds the image as Base64 encoded text into an HTML file.
 
static void CreateImageDiffHtml (plStringBuilder &out_sHtml, plStringView sTitle, const plImage &referenceImgRgb, const plImage &referenceImgAlpha, const plImage &capturedImgRgb, const plImage &capturedImgAlpha, const plImage &diffImgRgb, const plImage &diffImgAlpha, plUInt32 uiError, plUInt32 uiThreshold, plUInt8 uiMinDiffRgb, plUInt8 uiMaxDiffRgb, plUInt8 uiMinDiffAlpha, plUInt8 uiMaxDiffAlpha)
 Generates an HTML file containing the given images with mouse-over functionality to compare them.
 

Member Function Documentation

◆ BilinearSample() [1/2]

plColor plImageUtils::BilinearSample ( const plColor * pPixelPointer,
plUInt32 uiWidth,
plUInt32 uiHeight,
plImageAddressMode::Enum addressMode,
plVec2 vUv )
static

Samples the image at the given UV coordinates with bilinear filtering.

Prefer this function over the one that takes an plImageView when you need to sample the image very often, as it does away with internal validation that would be redundant. Also, the pixel pointer given to this function should be retrieved only once from the source image, as plImage::GetPixelPointer() is rather slow due to validation overhead.

◆ BilinearSample() [2/2]

plColor plImageUtils::BilinearSample ( const plImageView & image,
plImageAddressMode::Enum addressMode,
plVec2 vUv )
static

Samples the image at the given UV coordinates with bilinear filtering.

This function has to validate that the image is of the right format, and has to query the pixel pointer, which is slow. If you need to sample the image very often, use the overload that takes a pixel pointer instead of an image.

◆ Copy()

plResult plImageUtils::Copy ( const plImageView & srcImg,
const plRectU32 & srcRect,
plImage & ref_dstImg,
const plVec3U32 & vDstOffset,
plUInt32 uiDstMipLevel = 0,
plUInt32 uiDstFace = 0,
plUInt32 uiDstArrayIndex = 0 )
static

Copies the source image into the destination image at the specified location.

The image must fit, no scaling or cropping is done. Image formats must be identical. Compressed formats are not supported. If the target location leaves not enough room for the source image to be copied, bad stuff will happen.

◆ CopyChannel()

plResult plImageUtils::CopyChannel ( plImage & ref_dstImg,
plUInt8 uiDstChannelIdx,
const plImage & srcImg,
plUInt8 uiSrcChannelIdx )
static

Copies channel 0, 1, 2 or 3 from srcImg into dstImg.

Currently only supports images of format R32G32B32A32_FLOAT and with identical resolution. Returns failure if any of those requirements are not met.

◆ CreateCubemapFrom6Files()

plResult plImageUtils::CreateCubemapFrom6Files ( plImage & ref_dstImg,
const plImageView * pSourceImages )
static

Copies the 6 given source images to the faces of dstImg.

All input images must have the same square, power-of-two dimensions and mustn't be compressed.

◆ CreateCubemapFromSingleFile()

plResult plImageUtils::CreateCubemapFromSingleFile ( plImage & ref_dstImg,
const plImageView & srcImg )
static

Creates a cubemap from srcImg and stores it in dstImg.

If srcImg is already a cubemap, the data will be copied 1:1 to dstImg. If it is a 2D texture, it is analyzed and sub-images are copied to the proper faces of the output cubemap.

Supported input layouts are:

  • Vertical Cross
  • Horizontal Cross
  • Spherical mapping

◆ NearestSample() [1/2]

plColor plImageUtils::NearestSample ( const plColor * pPixelPointer,
plUInt32 uiWidth,
plUInt32 uiHeight,
plImageAddressMode::Enum addressMode,
plVec2 vUv )
static

Samples the image at the given UV coordinates with nearest filtering.

Prefer this function over the one that takes an plImageView when you need to sample the image very often, as it does away with internal validation that would be redundant. Also, the pixel pointer given to this function should be retrieved only once from the source image, as plImage::GetPixelPointer() is rather slow due to validation overhead.

◆ NearestSample() [2/2]

plColor plImageUtils::NearestSample ( const plImageView & image,
plImageAddressMode::Enum addressMode,
plVec2 vUv )
static

Samples the image at the given UV coordinates with nearest filtering.

This function has to validate that the image is of the right format, and has to query the pixel pointer, which is slow. If you need to sample the image very often, use the overload that takes a pixel pointer instead of an image.


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