Class TextureTool
Textures importing, processing and exporting utilities.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Tools/TextureTool/TextureTool.h
Syntax
public class TextureTool
Methods
Convert(TextureData& dst, const TextureData& src, const PixelFormat dstFormat)
Converts the specified source texture data into another format.
Declaration
public static bool Convert(TextureData& dst, const TextureData& src, const PixelFormat dstFormat)
Parameters
|
TextureData
dst
The destination data. |
|
TextureData
src
The source data. |
|
PixelFormat
dstFormat
The destination data format. Must be other than source data type. |
Returns
|
bool
True if fails, otherwise false. |
ExportTexture(const StringView& path, const TextureData& textureData)
Exports the texture.
Declaration
public static bool ExportTexture(const StringView& path, const TextureData& textureData)
Parameters
|
StringView
path
The output file path. |
|
TextureData
textureData
The output data. |
Returns
|
bool
True if fails, otherwise false. |
GetTextureFormat(TextureFormatType textureType, PixelFormat dataFormat, int32 width, int32 height, bool sRGB)
Calculates the runtime format for the texture pixels based on the texture type and input texture data (format and size). Checks the current GPUDevice formats support.
Declaration
public static PixelFormat GetTextureFormat(TextureFormatType textureType, PixelFormat dataFormat, int32 width, int32 height, bool sRGB)
Parameters
|
TextureFormatType
textureType
Type fo the texture that hints it's usage. |
|
PixelFormat
dataFormat
The existing texture data format (ideally to preserve to avoid conversions). |
|
int32
width
Width of the texture (in pixels). |
|
int32
height
Height of the texture (in pixels). |
|
bool
sRGB
Indicates that texture data is stored in sRGB color space. |
Returns
|
PixelFormat
Resolved pixel format for the GPU Texture. |
HasAlpha(const StringView& path)
Checks whenever the given texture file contains alpha channel data with values different from solid fill of 1 (non fully opaque).
Declaration
public static bool HasAlpha(const StringView& path)
Parameters
|
StringView
path
The file path. |
Returns
|
bool
True if has alpha channel, otherwise false. |
ImportTexture(const StringView& path, TextureData& textureData)
Imports the texture.
Declaration
public static bool ImportTexture(const StringView& path, TextureData& textureData)
Parameters
|
StringView
path
The file path. |
|
TextureData
textureData
The output data. |
Returns
|
bool
True if fails, otherwise false. |
ImportTexture(const StringView& path, TextureData& textureData, Options options, String& errorMsg)
Imports the texture.
Declaration
public static bool ImportTexture(const StringView& path, TextureData& textureData, Options options, String& errorMsg)
Parameters
|
StringView
path
The file path. |
|
TextureData
textureData
The output data. |
|
Options
options
The import options. |
|
String
errorMsg
The error message container. |
Returns
|
bool
True if fails, otherwise false. |
Resize(TextureData& dst, const TextureData& src, int32 dstWidth, int32 dstHeight)
Resizes the specified source texture data into another dimensions.
Declaration
public static bool Resize(TextureData& dst, const TextureData& src, int32 dstWidth, int32 dstHeight)
Parameters
|
TextureData
dst
The destination data. |
|
TextureData
src
The source data. |
|
int32
dstWidth
The destination data width. |
|
int32
dstHeight
The destination data height. |
Returns
|
bool
True if fails, otherwise false. |
ToPixelFormat(TextureFormatType format, int32 width, int32 height, bool canCompress=true)
Declaration
public static PixelFormat ToPixelFormat(TextureFormatType format, int32 width, int32 height, bool canCompress=true)
Parameters
|
TextureFormatType
format
|
|
int32
width
|
|
int32
height
|
|
bool
canCompress
|
Returns
|
PixelFormat
|
UpdateTexture(GPUContext* context, GPUTexture* texture, int32 arrayIndex, int32 mipIndex, Span<byte> data, uint32 rowPitch, uint32 slicePitch, PixelFormat dataFormat)
Updates the texture data. Supports transcoding source data (eg. Basis).
Declaration
public static bool UpdateTexture(GPUContext* context, GPUTexture* texture, int32 arrayIndex, int32 mipIndex, Span<byte> data, uint32 rowPitch, uint32 slicePitch, PixelFormat dataFormat)
Parameters
|
GPUContext
context
The GPU context. |
|
GPUTexture
texture
The destination GPU texture. It has to be allocated. |
|
int32
arrayIndex
The destination surface index in the texture array. |
|
int32
mipIndex
The absolute index of the mip map to update. |
|
Span<byte>
data
The buffer with texture the data. |
|
uint32
rowPitch
The row pitch (in bytes) of the input data. |
|
uint32
slicePitch
The slice pitch (in bytes) of the input data. |
|
PixelFormat
dataFormat
The format of the data. If different then GPU texture format then runtime conversion might happen. |
Returns
|
bool
|
WriteTextureData(BytesContainer& result, const TextureData& textureData, int32 mipIndex)
Declaration
public static bool WriteTextureData(BytesContainer& result, const TextureData& textureData, int32 mipIndex)
Parameters
|
BytesContainer
result
|
|
TextureData
textureData
|
|
int32
mipIndex
|
Returns
|
bool
|