UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FImageUtils Class Reference

#include <ImageUtils.h>

Static Public Member Functions

static ENGINE_API bool LoadImage (const TCHAR *Filename, FImage &OutImage)
 
static ENGINE_API bool SaveImageByExtension (const TCHAR *Filename, const FImageView &InImage, int32 Quality=0)
 
static ENGINE_API bool SaveImageAutoFormat (const TCHAR *Filename, const FImageView &InImage, int32 Quality=0)
 
static ENGINE_API bool CompressImage (TArray64< uint8 > &OutData, const TCHAR *ToFormatExtension, const FImageView &InImage, int32 Quality=0)
 
static ENGINE_API bool DecompressImage (const void *InCompressedData, int64 InCompressedSize, FImage &OutImage)
 
static ENGINE_API bool ExportTextureSourceToDDS (TArray64< uint8 > &OutData, UTexture *Texture, int BlockIndex=0, int LayerIndex=0)
 
static ENGINE_API bool ExportRenderTargetToDDS (TArray64< uint8 > &OutData, UTextureRenderTarget *TexRT)
 
static ENGINE_API bool GetTexture2DSourceImage (UTexture2D *Texture, FImage &OutImage)
 
static ENGINE_API void ImageResize (int32 SrcWidth, int32 SrcHeight, const TArray< FColor > &SrcData, int32 DstWidth, int32 DstHeight, TArray< FColor > &DstData, bool bResizeSRGBinLinearSpace, bool bForceOpaqueOutput=true)
 
static ENGINE_API void ImageResize (int32 SrcWidth, int32 SrcHeight, const TArrayView< const FColor > &SrcData, int32 DstWidth, int32 DstHeight, const TArrayView< FColor > &DstData, bool bResizeSRGBinLinearSpace, bool bForceOpaqueOutput=true)
 
static ENGINE_API void ImageResize (int32 SrcWidth, int32 SrcHeight, const TArray64< FLinearColor > &SrcData, int32 DstWidth, int32 DstHeight, TArray64< FLinearColor > &DstData)
 
static ENGINE_API void ImageResize (int32 SrcWidth, int32 SrcHeight, const TArrayView64< const FLinearColor > &SrcData, int32 DstWidth, int32 DstHeight, const TArrayView64< FLinearColor > &DstData)
 
static ENGINE_API UTexture2DCreateTexture2D (int32 SrcWidth, int32 SrcHeight, const TArray< FColor > &SrcData, UObject *Outer, const FString &Name, const EObjectFlags &Flags, const FCreateTexture2DParameters &InParams)
 
static ENGINE_API UTextureCreateTexture (ETextureClass TextureClass, const FImageView &Image, UObject *Outer, const FString &Name, EObjectFlags Flags=RF_NoFlags, bool DoPostEditChange=true)
 
static ENGINE_API UTexture2DCreateTexture2DFromImage (const FImageView &Image)
 
static ENGINE_API void CropAndScaleImage (int32 SrcWidth, int32 SrcHeight, int32 DesiredWidth, int32 DesiredHeight, const TArray< FColor > &SrcData, TArray< FColor > &DstData)
 
static ENGINE_API void ThumbnailCompressImageArray (int32 ImageWidth, int32 ImageHeight, const TArray< FColor > &SrcData, TArray< uint8 > &DstData)
 
static void CompressImageArray (int32 ImageWidth, int32 ImageHeight, const TArray< FColor > &SrcData, TArray< uint8 > &DstData)
 
static ENGINE_API void PNGCompressImageArray (int32 ImageWidth, int32 ImageHeight, const TArrayView64< const FColor > &SrcData, TArray64< uint8 > &DstData)
 
static ENGINE_API UTexture2DCreateCheckerboardTexture (FColor ColorOne=FColor(64, 64, 64), FColor ColorTwo=FColor(128, 128, 128), int32 CheckerSize=32)
 
static ENGINE_API UTexture2DArrayCreateCheckerboardTexture2DArray (FColor ColorOne=FColor(64, 64, 64), FColor ColorTwo=FColor(128, 128, 128), int32 CheckerSize=32, int32 ArraySize=1)
 
static ENGINE_API UTextureCubeCreateCheckerboardCubeTexture (FColor ColorOne=FColor(64, 64, 64), FColor ColorTwo=FColor(128, 128, 128), int32 CheckerSize=32)
 
static ENGINE_API UTextureCubeArrayCreateCheckerboardTextureCubeArray (FColor ColorOne=FColor(64, 64, 64), FColor ColorTwo=FColor(128, 128, 128), int32 CheckerSize=32, int32 ArraySize=1)
 
static ENGINE_API UVolumeTextureCreateCheckerboardVolumeTexture (FColor ColorOne=FColor(64, 64, 64), FColor ColorTwo=FColor(128, 128, 128), int32 CheckerSize=16)
 
static ENGINE_API bool ExportRenderTarget2DAsHDR (UTextureRenderTarget2D *TexRT, FArchive &Ar)
 
static ENGINE_API bool ExportRenderTarget2DAsEXR (UTextureRenderTarget2D *TexRT, FArchive &Ar)
 
static ENGINE_API bool ExportRenderTarget2DAsPNG (UTextureRenderTarget2D *TexRT, FArchive &Ar)
 
static ENGINE_API bool ExportTexture2DAsHDR (UTexture2D *TexRT, FArchive &Ar)
 
static ENGINE_API UTexture2DImportFileAsTexture2D (const FString &Filename)
 
static ENGINE_API UTexture2DImportBufferAsTexture2D (TArrayView64< const uint8 > Buffer)
 
static ENGINE_API UTexture2DImportBufferAsTexture2D (const TArray< uint8 > &Buffer)
 
static ENGINE_API bool ExportRenderTargetCubeAsHDR (UTextureRenderTargetCube *TexRT, FArchive &Ar)
 
static ENGINE_API bool ExportTextureCubeAsHDR (UTextureCube *TexRT, FArchive &Ar)
 
static ENGINE_API bool GetRawData (UTextureRenderTarget2D *TexRT, TArray64< uint8 > &RawData)
 
static ENGINE_API bool GetRenderTargetImage (UTextureRenderTarget *TexRT, FImage &OutImage)
 
static ENGINE_API bool GetRenderTargetImage (UTextureRenderTarget *TexRT, FImage &OutImage, const FIntRect &Rect)
 

Detailed Description

Class of static image utility functions.

Provides load/save of FImage and conversion from Texture2D/RenderTarget to/from FImage

in Engine, cannot be used by standalone texture build workers

Member Function Documentation

◆ CompressImage()

bool FImageUtils::CompressImage ( TArray64< uint8 > &  OutData,
const TCHAR ToFormatExtension,
const FImageView InImage,
int32  Quality = 0 
)
static

"Compress" an image to a file format. Here "Compress" really means put an image into file format binary. Extension is used to identify file format, eg. png/jpeg/etc. FImageView can be made from any surface pointer.

Parameters
OutDataFilled with file format Image data
ToFormatExtensioncan be a full name like "xxx.png" or just the extension like "png" ToFormatExtension == null is okay & means use default output format
InImageImage to save
QualityMainly for JPEG, but special values have some meaning for other formats

◆ CompressImageArray()

static void FImageUtils::CompressImageArray ( int32  ImageWidth,
int32  ImageHeight,
const TArray< FColor > &  SrcData,
TArray< uint8 > &  DstData 
)
inlinestatic

◆ CreateCheckerboardCubeTexture()

UTextureCube * FImageUtils::CreateCheckerboardCubeTexture ( FColor  ColorOne = FColor(64, 64, 64),
FColor  ColorTwo = FColor(128, 128, 128),
int32  CheckerSize = 32 
)
static

Creates a new UTextureCube with a checkerboard pattern.

Parameters
ColorOneThe color of half of the squares.
ColorTwoThe color of the other half of the squares.
CheckerSizeThe size in pixels of each side of the texture.

◆ CreateCheckerboardTexture()

UTexture2D * FImageUtils::CreateCheckerboardTexture ( FColor  ColorOne = FColor(64, 64, 64),
FColor  ColorTwo = FColor(128, 128, 128),
int32  CheckerSize = 32 
)
static

Creates a new UTexture2D with a checkerboard pattern.

Parameters
ColorOneThe color of half of the squares.
ColorTwoThe color of the other half of the squares.
CheckerSizeThe size in pixels of each side of the texture.

◆ CreateCheckerboardTexture2DArray()

UTexture2DArray * FImageUtils::CreateCheckerboardTexture2DArray ( FColor  ColorOne = FColor(64, 64, 64),
FColor  ColorTwo = FColor(128, 128, 128),
int32  CheckerSize = 32,
int32  ArraySize = 1 
)
static

Creates a new UTexture2DArray with a checkerboard pattern.

Parameters
ColorOneThe color of half of the squares.
ColorTwoThe color of the other half of the squares.
CheckerSizeThe size in pixels of each side of the texture.
ArraySizeThe number of elements in the array.

◆ CreateCheckerboardTextureCubeArray()

UTextureCubeArray * FImageUtils::CreateCheckerboardTextureCubeArray ( FColor  ColorOne = FColor(64, 64, 64),
FColor  ColorTwo = FColor(128, 128, 128),
int32  CheckerSize = 32,
int32  ArraySize = 1 
)
static

Creates a new UTextureCubeArray with a checkerboard pattern.

Parameters
ColorOneThe color of half of the squares.
ColorTwoThe color of the other half of the squares.
CheckerSizeThe size in pixels of each side of the texture.
ArraySizeThe number of elements in the array.

◆ CreateCheckerboardVolumeTexture()

UVolumeTexture * FImageUtils::CreateCheckerboardVolumeTexture ( FColor  ColorOne = FColor(64, 64, 64),
FColor  ColorTwo = FColor(128, 128, 128),
int32  CheckerSize = 16 
)
static

Creates a new UVolumeTexture with a checkerboard pattern.

Parameters
ColorOneThe color of half of the squares.
ColorTwoThe color of the other half of the squares.
CheckerSizeThe size in pixels of each side of the texture.

◆ CreateTexture()

UTexture * FImageUtils::CreateTexture ( ETextureClass  TextureClass,
const FImageView Image,
UObject Outer,
const FString &  Name,
EObjectFlags  Flags = RF_NoFlags,
bool  DoPostEditChange = true 
)
static

Creates a texture of any type from an Image This is the modern preferred way to create a texture.

If you need to change the default settings, then use DoPostEditChange = false, and call PostEditChange() yourself after setting all properties. Typically you may want to set LODGroup and CompressionSettings.

this fills the TextureSource , and will then Build a Platform texture from that can be used WITH_EDITOR only

◆ CreateTexture2D()

UTexture2D * FImageUtils::CreateTexture2D ( int32  SrcWidth,
int32  SrcHeight,
const TArray< FColor > &  SrcData,
UObject Outer,
const FString &  Name,
const EObjectFlags Flags,
const FCreateTexture2DParameters InParams 
)
static

Creates a 2D texture from a array of raw color data.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
OuterOuter for the texture object.
NameName for the texture object.
FlagsObject flags for the texture object.
InParamsParams about how to set up the texture.
Returns
Returns a pointer to the constructed 2D texture object.

this fills a TextureSource , and will then Build a Platform texture from that can be used WITH_EDITOR only contrast to CreateTexture2DFromImage

Prefer the more modern CreateTexture from FImage.

Creates a 2D texture from a array of raw color data.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
OuterOuter for the texture object.
NameName for the texture object.
FlagsObject flags for the texture object.
InParamsParams about how to set up the texture.
Returns
Returns a pointer to the constructed 2D texture object.

◆ CreateTexture2DFromImage()

UTexture2D * FImageUtils::CreateTexture2DFromImage ( const FImageView Image)
static

Creates a 2D texture from an FImage

Parameters
ImageImage that will be copied into a Texture
Returns
Returns a pointer to the constructed 2D texture object.

NOTE: this makes a Transient texture with the Image in the PlatformData this is different than making a Texture via TextureSource.Init(Image)

◆ CropAndScaleImage()

void FImageUtils::CropAndScaleImage ( int32  SrcWidth,
int32  SrcHeight,
int32  DesiredWidth,
int32  DesiredHeight,
const TArray< FColor > &  SrcData,
TArray< FColor > &  DstData 
)
static

Crops, and scales an image from a raw image array.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
DesiredWidthDesired Width.
DesiredHeightDesired Height.
SrcDataRaw image array.
DstDatacompressed image array.

◆ DecompressImage()

bool FImageUtils::DecompressImage ( const void InCompressedData,
int64  InCompressedSize,
FImage OutImage 
)
static

"Decompress" an image to a file format. Here "Compress" really means put an image into file format binary.

Parameters
InCompressedDataFile formatted image bits to unpack
InCompressedSizeSize of InCompressedData
OutImageFilled with the decompressed image and allocated as needed

◆ ExportRenderTarget2DAsEXR()

bool FImageUtils::ExportRenderTarget2DAsEXR ( UTextureRenderTarget2D TexRT,
FArchive Ar 
)
static

Exports a UTextureRenderTarget2D as a EXR image on the disk. Deprecated. Prefer GetRenderTargetImage.

Parameters
TexRTThe render target to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportRenderTarget2DAsHDR()

bool FImageUtils::ExportRenderTarget2DAsHDR ( UTextureRenderTarget2D TexRT,
FArchive Ar 
)
static

Exports a UTextureRenderTarget2D as an HDR image on the disk. HDR is very low quality, prefer EXR or PNG instead Deprecated. Prefer GetRenderTargetImage.

Parameters
TexRTThe render target to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportRenderTarget2DAsPNG()

bool FImageUtils::ExportRenderTarget2DAsPNG ( UTextureRenderTarget2D TexRT,
FArchive Ar 
)
static

Exports a UTextureRenderTarget2D as a PNG image on the disk. Deprecated. Prefer GetRenderTargetImage.

Parameters
TexRTThe render target to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportRenderTargetCubeAsHDR()

bool FImageUtils::ExportRenderTargetCubeAsHDR ( UTextureRenderTargetCube TexRT,
FArchive Ar 
)
static

Exports a UTextureRenderTargetCube as an HDR image on the disk. this does GenerateLongLatUnwrap

Parameters
TexRTThe render target cube to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportRenderTargetToDDS()

bool FImageUtils::ExportRenderTargetToDDS ( TArray64< uint8 > &  OutData,
UTextureRenderTarget TexRT 
)
static

Export Texture RenderTarget (2D,Array,Cube,CubeArray,Volume) to DDS reads from texture rendertarget RHI texture

Parameters
OutDataFilled with DDS file format
TexRTTexture RenderTarget (2D,Array,Cube,CubeArray,Volume) to export

◆ ExportTexture2DAsHDR()

bool FImageUtils::ExportTexture2DAsHDR ( UTexture2D TexRT,
FArchive Ar 
)
static

Exports a UTexture2D as an HDR image on the disk. Deprecated. Prefer GetTexture2DSourceImage + SaveImage. HDR is very low quality, prefer EXR or PNG instead

Parameters
TexRTThe texture to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportTextureCubeAsHDR()

bool FImageUtils::ExportTextureCubeAsHDR ( UTextureCube TexRT,
FArchive Ar 
)
static

Exports a UTextureCube as an HDR image on the disk. this does GenerateLongLatUnwrap

Parameters
TexRTThe texture cube to export
ArArchive to fill with data.
Returns
Export operation success or failure.

◆ ExportTextureSourceToDDS()

bool FImageUtils::ExportTextureSourceToDDS ( TArray64< uint8 > &  OutData,
UTexture Texture,
int  BlockIndex = 0,
int  LayerIndex = 0 
)
static

Export Texture (2D,Array,Cube,CubeArray,Volume) to DDS reads from texture source, not platform data

Parameters
OutDataFilled with DDS file format
TextureTexture (2D,Array,Cube,CubeArray,Volume) to export
BlockIndexBlock to export (optional)
LayerIndexLayer to export (optional)

◆ GetRawData()

bool FImageUtils::GetRawData ( UTextureRenderTarget2D TexRT,
TArray64< uint8 > &  RawData 
)
static

◆ GetRenderTargetImage() [1/2]

bool FImageUtils::GetRenderTargetImage ( UTextureRenderTarget TexRT,
FImage OutImage 
)
static

Get the contents of a RenderTarget into an Image

Parameters
TexRTThe texture rendertarget to copy from
OutImageFilled with the image, allocated as needed

Works for Cubes, Volumes, etc. (fills Image slices)

◆ GetRenderTargetImage() [2/2]

bool FImageUtils::GetRenderTargetImage ( UTextureRenderTarget TexRT,
FImage OutImage,
const FIntRect Rect 
)
static

◆ GetTexture2DSourceImage()

bool FImageUtils::GetTexture2DSourceImage ( UTexture2D Texture,
FImage OutImage 
)
static

if Texture source is available, get it as an FImage

Parameters
TextureTexture to get gets from
OutImageFilled with the image copy and allocated as needed

◆ ImageResize() [1/4]

void FImageUtils::ImageResize ( int32  SrcWidth,
int32  SrcHeight,
const TArray64< FLinearColor > &  SrcData,
int32  DstWidth,
int32  DstHeight,
TArray64< FLinearColor > &  DstData 
)
static

Resizes the given image using FImageCore::ResizeImage. Destination array will be emptied and resized.

prefer FImageCore::ResizeImage instead. prefer using FImage or FImageView not FColor arrays.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
DstWidthDestination image width.
DstHeightDestination image height.
DstDataDestination image data. (will be resized)

BEWARE: the FColor variant of this function fills with opaque alpha by default. The FLinearColor variant does not

◆ ImageResize() [2/4]

void FImageUtils::ImageResize ( int32  SrcWidth,
int32  SrcHeight,
const TArray< FColor > &  SrcData,
int32  DstWidth,
int32  DstHeight,
TArray< FColor > &  DstData,
bool  bResizeSRGBinLinearSpace,
bool  bForceOpaqueOutput = true 
)
static

Resizes the given image using FImageCore::ResizeImage. Destination array will be emptied and resized.

prefer FImageCore::ResizeImage instead. prefer using FImage or FImageView not FColor arrays.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
DstWidthDestination image width.
DstHeightDestination image height.
DstDataDestination image data. (will be resized)
bResizeSRGBinLinearSpaceConvert sRGB to linear for gamma-correct resize. Should be true if the Src is SRGB diffuse color; should be false for masks and normal maps.
bForceOpaqueOutputAlways output 255 for the alpha channel. BEWARE defaults to true so alpha is killed by default.

BEWARE: the FColor variant of this function fills with opaque alpha by default. The FLinearColor variant does not

◆ ImageResize() [3/4]

void FImageUtils::ImageResize ( int32  SrcWidth,
int32  SrcHeight,
const TArrayView64< const FLinearColor > &  SrcData,
int32  DstWidth,
int32  DstHeight,
const TArrayView64< FLinearColor > &  DstData 
)
static

Resizes the given image using FImageCore::ResizeImage. Accepts TArrayViews but requires that DstData be pre-sized appropriately

prefer FImageCore::ResizeImage instead. prefer using FImage or FImageView not FColor arrays.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
DstWidthDestination image width.
DstHeightDestination image height.
DstDataDestination image data. (must already be sized to DstWidth*DstHeight)

BEWARE: the FColor variant of this function fills with opaque alpha by default. The FLinearColor variant does not

◆ ImageResize() [4/4]

void FImageUtils::ImageResize ( int32  SrcWidth,
int32  SrcHeight,
const TArrayView< const FColor > &  SrcData,
int32  DstWidth,
int32  DstHeight,
const TArrayView< FColor > &  DstData,
bool  bResizeSRGBinLinearSpace,
bool  bForceOpaqueOutput = true 
)
static

Resizes the given image using FImageCore::ResizeImage. Accepts TArrayViews but requires that DstData be pre-sized appropriately

prefer FImageCore::ResizeImage instead. prefer using FImage or FImageView not FColor arrays.

Parameters
SrcWidthSource image width.
SrcHeightSource image height.
SrcDataSource image data.
DstWidthDestination image width.
DstHeightDestination image height.
DstDataDestination image data. (must already be sized to DstWidth*DstHeight)
bResizeSRGBinLinearSpaceConvert sRGB to linear for gamma-correct resize. Should be true if the Src is SRGB diffuse color; should be false for masks and normal maps.
bForceOpaqueOutputAlways output 255 for the alpha channel. BEWARE defaults to true so alpha is killed by default.

BEWARE: the FColor variant of this function fills with opaque alpha by default. The FLinearColor variant does not

◆ ImportBufferAsTexture2D() [1/2]

UTexture2D * FImageUtils::ImportBufferAsTexture2D ( const TArray< uint8 > &  Buffer)
static

◆ ImportBufferAsTexture2D() [2/2]

UTexture2D * FImageUtils::ImportBufferAsTexture2D ( TArrayView64< const uint8 Buffer)
static

Imports a texture a buffer and creates Texture2D from it

note this make a Transient / PlatformData only Texture (no TextureSource)

◆ ImportFileAsTexture2D()

UTexture2D * FImageUtils::ImportFileAsTexture2D ( const FString &  Filename)
static

Imports a texture file from disk and creates Texture2D from it

note this make a Transient / PlatformData only Texture (no TextureSource)

◆ LoadImage()

bool FImageUtils::LoadImage ( const TCHAR Filename,
FImage OutImage 
)
static

Load an image of any type supported by the ImageWrapper module

Parameters
FilenameFile name to load
OutImageFilled with the loaded image, allocated as needed

◆ PNGCompressImageArray()

void FImageUtils::PNGCompressImageArray ( int32  ImageWidth,
int32  ImageHeight,
const TArrayView64< const FColor > &  SrcData,
TArray64< uint8 > &  DstData 
)
static

Compress image to PNG format uint8 array. deprecated, use CompressImage instead

Parameters
ImageHeightSource image width.
ImageWidthSource image height.
SrcDataRaw image array.
DstDatacompressed image array.

◆ SaveImageAutoFormat()

bool FImageUtils::SaveImageAutoFormat ( const TCHAR Filename,
const FImageView InImage,
int32  Quality = 0 
)
static

Save an image. Output format will be chosen automatically based on the Image pixel format eg. EXR for float, PNG for BGRA8 extension will be added to file name

Parameters
FilenameFile name to save to, auto extension will be added
InImageImage to save
QualityMainly for JPEG, but special values have some meaning for other formats

◆ SaveImageByExtension()

bool FImageUtils::SaveImageByExtension ( const TCHAR Filename,
const FImageView InImage,
int32  Quality = 0 
)
static

Save an image. Extension of Filename will be used for output image file format. FImageView can be made from any surface pointer.

Parameters
FilenameFile name to save to, with extension to identify format
InImageImage to save
QualityMainly for JPEG, but special values have some meaning for other formats

If Filename has no extension, an appropriate one is automatically generated based on image format.

◆ ThumbnailCompressImageArray()

void FImageUtils::ThumbnailCompressImageArray ( int32  ImageWidth,
int32  ImageHeight,
const TArray< FColor > &  SrcData,
TArray< uint8 > &  DstData 
)
static

Compress image to thumbnail enabled format (png or jpg) uint8 array.

Parameters
ImageHeightSource image width.
ImageWidthSource image height.
SrcDataRaw image array.
DstDatacompressed image array.

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