VTFLib
A C and C++ API that, with a few simple functions, can open and save .vtf and .vmt files.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions
VTFLib::CVTFFile Class Reference

VTF File access/creation class. More...

#include <VTFFile.h>

Public Member Functions

 CVTFFile ()
 Default constructor.
 
 CVTFFile (const CVTFFile &VTFFile)
 Create a new VTFFile class as a copy of another. More...
 
 CVTFFile (const CVTFFile &VTFFile, VTFImageFormat ImageFormat)
 Create a new VTFFile class as a duplicate of another. More...
 
 ~CVTFFile ()
 Deconstructor.
 
vlBool Create (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiFrames=1, vlUInt uiFaces=1, vlUInt uiSlices=1, VTFImageFormat ImageFormat=IMAGE_FORMAT_RGBA8888, vlBool bThumbnail=vlTrue, vlBool bMipmaps=vlTrue, vlBool bNullImageData=vlFalse)
 Creates a new empty VTF image.. More...
 
vlBool Create (vlUInt uiWidth, vlUInt uiHeight, vlByte *lpImageDataRGBA8888, const SVTFCreateOptions &VTFCreateOptions)
 Create a new VTF image from existing data. More...
 
vlBool Create (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiFrames, vlUInt uiFaces, vlUInt vlSlices, vlByte **lpImageDataRGBA8888, const SVTFCreateOptions &VTFCreateOptions)
 Create a new VTF multi-frame or cubemap image from existing data. More...
 
vlVoid Destroy ()
 Destroys the current VTF image by setting the header, thumbnail and image data to zero.
 
vlBool IsLoaded () const
 Check if a VTFFile image is loaded or valid. More...
 
vlBool Load (const vlChar *cFileName, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image from disk. More...
 
vlBool Load (const vlVoid *lpData, vlSize uiBufferSize, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image from memory. More...
 
vlBool Load (vlVoid *pUserData, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image using callback functions. More...
 
vlBool Save (const vlChar *cFileName) const
 Save a VTF image from disk. More...
 
vlBool Save (vlVoid *lpData, vlSize uiBufferSize, vlSize &uiSize) const
 Save a VTF image to memory. More...
 
vlBool Save (vlVoid *pUserData) const
 Save a VTF image using callback functions. More...
 
vlBool GetHasImage () const
 Check if image data has been loaded. More...
 
vlUInt GetMajorVersion () const
 Returns the VTF file major version number.
 
vlUInt GetMinorVersion () const
 Returns the VTF file minor version number.
 
vlUInt GetSize () const
 Returns the VTF file size in bytes.
 
vlUInt GetWidth () const
 Returns the width of the image in pixels from the VTF header.
 
vlUInt GetHeight () const
 Returns the height of the image in pixels from the VTF header.
 
vlUInt GetDepth () const
 Returns the depth of the image in pixels from the VTF header.
 
vlUInt GetFrameCount () const
 Returns the frame count from the VTF header.
 
vlUInt GetFaceCount () const
 Returns the face count from the VTF header.
 
vlUInt GetMipmapCount () const
 Returns the number of MIP levels in the image from the VTF header.
 
vlUInt GetStartFrame () const
 Returns the start frame from the VTF header.
 
vlVoid SetStartFrame (vlUInt uiStartFrame)
 Sets the start frame in the VTF header.
 
vlUInt GetFlags () const
 Returns the image flags from the VTF header.
 
vlVoid SetFlags (vlUInt uiFlags)
 Sets the image flags in the VTF header.
 
vlBool GetFlag (VTFImageFlag ImageFlag) const
 Check if a specific flag is set in the VTF header. More...
 
vlVoid SetFlag (VTFImageFlag ImageFlag, vlBool bState)
 Set the state of a specific flag in the VTF header. More...
 
vlSingle GetBumpmapScale () const
 Get the bump scale value.
 
vlVoid SetBumpmapScale (vlSingle sBumpmapScale)
 Set the bump scale value. More...
 
vlVoid GetReflectivity (vlSingle &sX, vlSingle &sY, vlSingle &sZ) const
 Get the reflectivity values. More...
 
vlVoid SetReflectivity (vlSingle sX, vlSingle sY, vlSingle sZ)
 Set the reflectivity values. More...
 
VTFImageFormat GetFormat () const
 Returns the storage format of the main image data set in the VTF header.
 
vlByteGetData (vlUInt uiFrame, vlUInt uiFace, vlUInt uiSlice, vlUInt uiMipmapLevel) const
 Get a pointer to the image data for a specific image. More...
 
vlVoid SetData (vlUInt uiFrame, vlUInt uiFace, vlUInt uiSlice, vlUInt uiMipmapLevel, vlByte *lpData)
 Set the image data for a specific image. More...
 
vlBool GetHasThumbnail () const
 Returns if a the current VTF image image contains a thumbnail version.
 
vlUInt GetThumbnailWidth () const
 Returns the width in pixels of the current images thumbnail.
 
vlUInt GetThumbnailHeight () const
 Returns the heught in pixels of the current images thumbnail.
 
VTFImageFormat GetThumbnailFormat () const
 Returns the image format of the current images thumbnail.
 
vlByteGetThumbnailData () const
 Get a pointer to the thumbnail image data for the current image. More...
 
vlVoid SetThumbnailData (vlByte *lpData)
 Set the thumbnail image data for the current image. More...
 
vlBool GetSupportsResources () const
 Returns true if the current VTF file version supports resources.
 
vlUInt GetResourceCount () const
 Returns the number of resources contained within the VTF file.
 
vlUInt GetResourceType (vlUInt uiIndex) const
 Returns the resource type;.
 
vlBool GetHasResource (vlUInt uiType) const
 Returns true if the resource exists.
 
vlVoidGetResourceData (vlUInt uiType, vlUInt &uiSize) const
 Get a VTF resource type's data. More...
 
vlVoidSetResourceData (vlUInt uiType, vlUInt uiSize, vlVoid *lpData)
 Set a VTF resource type's data. More...
 
vlBool GenerateMipmaps (VTFMipmapFilter MipmapFilter=MIPMAP_FILTER_BOX, VTFSharpenFilter SharpenFilter=SHARPEN_FILTER_NONE)
 Generate MIP maps from the main image data. More...
 
vlBool GenerateMipmaps (vlUInt uiFace, vlUInt uiFrame, VTFMipmapFilter MipmapFilter=MIPMAP_FILTER_BOX, VTFSharpenFilter SharpenFilter=SHARPEN_FILTER_NONE)
 Generate MIP maps from a specific face and frame. More...
 
vlBool GenerateThumbnail ()
 Generate a thumbnail image. More...
 
vlBool GenerateNormalMap (VTFKernelFilter KernelFilter=KERNEL_FILTER_3X3, VTFHeightConversionMethod HeightConversionMethod=HEIGHT_CONVERSION_METHOD_AVERAGE_RGB, VTFNormalAlphaResult NormalAlphaResult=NORMAL_ALPHA_RESULT_WHITE)
 Convert image to a normal map. More...
 
vlBool GenerateNormalMap (vlUInt uiFrame, VTFKernelFilter KernelFilter=KERNEL_FILTER_3X3, VTFHeightConversionMethod HeightConversionMethod=HEIGHT_CONVERSION_METHOD_AVERAGE_RGB, VTFNormalAlphaResult NormalAlphaResult=NORMAL_ALPHA_RESULT_WHITE)
 Convert image to a normal map from a specific frame. More...
 
vlBool GenerateSphereMap ()
 Creates a spheremap from using the 6 faces of the image making up its cubemap.
 
vlBool ComputeReflectivity ()
 Calculates and sets the reflectivity vector values for the VTF image based on the colour averages of each pixel.
 

Static Public Member Functions

static SVTFImageFormatInfo const & GetImageFormatInfo (VTFImageFormat ImageFormat)
 Get VTFImageFormat info. More...
 
static vlUInt ComputeImageSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, VTFImageFormat ImageFormat)
 Calculate data buffer size for an image. More...
 
static vlUInt ComputeImageSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, vlUInt uiMipmaps, VTFImageFormat ImageFormat)
 Calculate data buffer size for an image with MIP maps. More...
 
static vlUInt ComputeMipmapCount (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth)
 Compute the number of MIP maps needed by an image. More...
 
static vlVoid ComputeMipmapDimensions (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, vlUInt uiMipmapLevel, vlUInt &uiMipmapWidth, vlUInt &uiMipmapHeight, vlUInt &uiMipmapDepth)
 Compute the dimensions of a specific MIP level. More...
 
static vlUInt ComputeMipmapSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, vlUInt uiMipmapLevel, VTFImageFormat ImageFormat)
 Compute how much memory a specific MIP map level needs. More...
 
static vlBool ConvertToRGBA8888 (const vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat SourceFormat)
 Convert an image to RGBA8888 format. More...
 
static vlBool ConvertFromRGBA8888 (const vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat DestFormat)
 Convert an image from RGBA8888 format. More...
 
static vlBool Convert (const vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat SourceFormat, VTFImageFormat DestFormat)
 Convert an image from any format to any format. More...
 
static vlBool ConvertToNormalMap (const vlByte *lpSourceRGBA8888, vlByte *lpDestRGBA8888, vlUInt uiWidth, vlUInt uiHeight, VTFKernelFilter KernelFilter=KERNEL_FILTER_3X3, VTFHeightConversionMethod HeightConversionMethod=HEIGHT_CONVERSION_METHOD_AVERAGE_RGB, VTFNormalAlphaResult NormalAlphaResult=NORMAL_ALPHA_RESULT_WHITE, vlByte bMinimumZ=0, vlSingle sScale=2.0f, vlBool bWrap=vlFalse, vlBool bInvertX=vlFalse, vlBool bInvertY=vlFalse, vlBool bInvertZ=vlFalse)
 Convert an image to a normal map. More...
 
static vlBool Resize (const vlByte *lpSourceRGBA8888, vlByte *lpDestRGBA8888, vlUInt uiSourceWidth, vlUInt uiSourceHeight, vlUInt uiDestWidth, vlUInt uiDestHeight, VTFMipmapFilter ResizeFilter=MIPMAP_FILTER_TRIANGLE, VTFSharpenFilter SharpenFilter=SHARPEN_FILTER_NONE)
 Re-sizes an image. More...
 
static vlVoid CorrectImageGamma (vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight, vlSingle sGammaCorrection)
 Correct and images gamma. More...
 
static vlVoid ComputeImageReflectivity (const vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight, vlSingle &sX, vlSingle &sY, vlSingle &sZ)
 Computes the reflectivity for an image. More...
 
static vlVoid FlipImage (vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight)
 Flips an image vertically along its X-axis.
 
static vlVoid MirrorImage (vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight)
 Flips an image horizontally along its Y-axis.
 

Detailed Description

VTF File access/creation class.

The CVTFFile class is the component designed for working with VTF format image files. Its public functions allow you to load, save and create new VTF files plus perform various processes on the image data such as the generation of MIP maps or Normal maps.

VTFFile generally use RGBA8888 format for passing data to and from functions. This is 4 bytes per pixel, 8-bits per channel colour or in short, uncompressed 32-bit image data. There are functions for converting the data to other formats internally, however for image creation you are probably sticking best with RGBA8888 for simplicity.

The majority of functions return a vlBool value. This is simply a test as to whether a function has succeeded or failed to execute properly. In the case of functions for checking flags, the vlBool indicates if the flag is set or unset. Other data types reflect the purpose of the function used.

Constructor & Destructor Documentation

CVTFFile::CVTFFile ( const CVTFFile VTFFile)

Create a new VTFFile class as a copy of another.

Creates a new VTFFile class as a copy of an existing one. The copy is not linked so any changes to it will not effect the class instance it was derived from.

Parameters
VTFFileis the CVTFFile class you want to copy.
CVTFFile::CVTFFile ( const CVTFFile VTFFile,
VTFImageFormat  ImageFormat 
)

Create a new VTFFile class as a duplicate of another.

Create a new VTFFile class as a duplicate of an existing one, but convert the image data to the specified format.

Parameters
VTFFileis the CVTFFile class you want to copy.
ImageFormatthe format you want to convert the copied image data to.

Member Function Documentation

vlVoid CVTFFile::ComputeImageReflectivity ( const vlByte lpImageDataRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight,
vlSingle sX,
vlSingle sY,
vlSingle sZ 
)
static

Computes the reflectivity for an image.

Calculates and sets the reflectivity vector values for the VTF image based on the colour averages of each pixel.

Parameters
lpImageDataRGBA8888is a pointer to the image data in RGBA8888 format.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
sX,sY,sZare the variables to hold the values reflectivity vector.
See Also
ComputeReflectivity()
GetReflectivity()
SetReflectivity()
vlUInt CVTFFile::ComputeImageSize ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiDepth,
VTFImageFormat  ImageFormat 
)
static

Calculate data buffer size for an image.

Returns the total memory needed in bytes for an image uiWidth and uiHeight in size, in the specified format. The result includes the memory used by all MIP map levels from the largest dimension down to 1 x 1 pixel.

Parameters
uiWidthis the width in pixels of the largest MIP level.
uiHeightis the height in pixels of the largest MIP level.
uiDepthis the depth in pixels of the largest MIP level.
ImageFormatis the storage format of the image data.
Returns
size of the image data in bytes.
vlUInt CVTFFile::ComputeImageSize ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiDepth,
vlUInt  uiMipmaps,
VTFImageFormat  ImageFormat 
)
static

Calculate data buffer size for an image with MIP maps.

Returns the total memory needed in bytes for an image uiWidth and uiHeight in size, in the specified format. The result includes the memory used by the number of MIP maps given as uiMipmaps starting with the original width and height.

Parameters
uiWidthis the width in pixels of the largest MIP level.
uiHeightis the height in pixels of the largest MIP level.
uiDepthis the depth in pixels of the largest MIP level.
uiMipmapsis the number of MIP maps to include in the calculation starting with the largest.
ImageFormatis the storage format of the image data.
Returns
size of the image data in bytes.
vlUInt CVTFFile::ComputeMipmapCount ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiDepth 
)
static

Compute the number of MIP maps needed by an image.

Returns how many MIP map levels an image of the specified size will need down to 1 x 1 pixels. The count includes the original source image.

Parameters
uiWidthis the width in pixels of the original image.
uiHeightis the height in pixels of the original image.
uiDepthis the depth in pixels of the original image.
Returns
number of MIP maps needed.Returns how many MIP map levels are required for an image uiWidth and uiHeight in size, down to 1x1 pixel.
vlVoid CVTFFile::ComputeMipmapDimensions ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiDepth,
vlUInt  uiMipmapLevel,
vlUInt uiMipmapWidth,
vlUInt uiMipmapHeight,
vlUInt uiMipmapDepth 
)
static

Compute the dimensions of a specific MIP level.

Returns the dimensions of a given MIP level where the largest MIP level (level 0) is the specified width and height.

Parameters
uiWidthis the width in pixels of the largest MIP level.
uiHeightis the height in pixels of the largest MIP level.
uiDepthis the depth in pixels of the largest MIP level.
uiMipmapLevelis the MIP level you want the dimensions of.
uiMipmapWidthis the variable to hold the calculated width.
uiMipmapHeightis the variable to hold the calculated height.
uiMipmapDepthis the variable to hold the calculated depth.
vlUInt CVTFFile::ComputeMipmapSize ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiDepth,
vlUInt  uiMipmapLevel,
VTFImageFormat  ImageFormat 
)
static

Compute how much memory a specific MIP map level needs.

Computers the total memory needed in bytes for the a specific MIP map level of an image of a given width and height stored in the specified image format.

Parameters
uiWidthis the width in pixels of the source image.
uiHeightis the height in pixels of the source image.
uiDepthis the depth in pixels of the source image.
uiMipmapLevelis the MIP level you want the size of.
ImageFormatis the image format the MIP map image data is stored in.
Returns
size of the MIP map image data in bytes.
vlBool CVTFFile::Convert ( const vlByte lpSource,
vlByte lpDest,
vlUInt  uiWidth,
vlUInt  uiHeight,
VTFImageFormat  SourceFormat,
VTFImageFormat  DestFormat 
)
static

Convert an image from any format to any format.

Converts image data stored in any format to the the specified storage format.

Parameters
lpSourceis a pointer to the source image data.
lpDestis a pointer to the buffer for the converted data.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
SourceFormatis the image format you are converting from.
DestFormatis the image format you wish to convert to.
Returns
true on sucessful conversion, otherwise false.
vlBool CVTFFile::ConvertFromRGBA8888 ( const vlByte lpSource,
vlByte lpDest,
vlUInt  uiWidth,
vlUInt  uiHeight,
VTFImageFormat  DestFormat 
)
static

Convert an image from RGBA8888 format.

Converts image data stored in RGBA8888 format to the the specified storage format.

Parameters
lpSourceis a pointer to the source image data in RGBA8888 format.
lpDestis a pointer to the buffer for the converted data.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
DestFormatis the image format you wish to convert to.
Returns
true on sucessful conversion, otherwise false.
vlBool CVTFFile::ConvertToNormalMap ( const vlByte lpSourceRGBA8888,
vlByte lpDestRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight,
VTFKernelFilter  KernelFilter = KERNEL_FILTER_3X3,
VTFHeightConversionMethod  HeightConversionMethod = HEIGHT_CONVERSION_METHOD_AVERAGE_RGB,
VTFNormalAlphaResult  NormalAlphaResult = NORMAL_ALPHA_RESULT_WHITE,
vlByte  bMinimumZ = 0,
vlSingle  sScale = 2.0f,
vlBool  bWrap = vlFalse,
vlBool  bInvertX = vlFalse,
vlBool  bInvertY = vlFalse,
vlBool  bInvertZ = vlFalse 
)
static

Convert an image to a normal map.

Converts image data stored in RGBA8888 format to a normal map.

Parameters
lpSourceRGBA8888is a pointer to the source image data in RGBA8888 format.
lpDestRGBA8888is a pointer to the buffer for the converted data.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
KernelFilteris the kernel filter to use (default 3x3).
HeightConversionMethodis the method of determining the height data from the source (default average RGB).
NormalAlphaResultis how the alpha channel should be handled post processing (defaul make 100% opaque).
bMinimumZis the minimum normal Z value (default 0).
sScaleis the normal map height scale (default 2).
bWrapsets whether the normal map should be tileable (default false).
bInvertXsets if the normal map should be flipped along its X axis (default false).
bInvertYsets if the normal map should be flipped along its Y axis (default false).
bInvertZsets if the normal map should be flipped along its Z axis (default false).
Returns
true on sucessful conversion, otherwise false.
vlBool CVTFFile::ConvertToRGBA8888 ( const vlByte lpSource,
vlByte lpDest,
vlUInt  uiWidth,
vlUInt  uiHeight,
VTFImageFormat  SourceFormat 
)
static

Convert an image to RGBA8888 format.

Converts image data stored in the given format to RGBA8888 format.

Parameters
lpSourceis a pointer to the source image data.
lpDestis a pointer to the buffer for the converted data.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
SourceFormatis the image format of the source data.
Returns
true on sucessful conversion, otherwise false.
vlVoid CVTFFile::CorrectImageGamma ( vlByte lpImageDataRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight,
vlSingle  sGammaCorrection 
)
static

Correct and images gamma.

Applies gamma correction to an image.

Parameters
lpImageDataRGBA8888is a pointer to the image data in RGBA8888 format.
uiWidthis the width of the source image in pixels.
uiHeightis the height of the source image in pixels.
sGammaCorrectionis the amount of gamma correction to apply.
vlBool CVTFFile::Create ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiFrames = 1,
vlUInt  uiFaces = 1,
vlUInt  uiSlices = 1,
VTFImageFormat  ImageFormat = IMAGE_FORMAT_RGBA8888,
vlBool  bThumbnail = vlTrue,
vlBool  bMipmaps = vlTrue,
vlBool  bNullImageData = vlFalse 
)

Creates a new empty VTF image..

Creates a new empty VTF format image within a the current CVTFFile class.

Parameters
uiWidthis the width in pixels of the main VTF image.
uiHeightis the height in pixels of the main VTF image.
uiFramesis the number of frames in the VTF image (default 1).
uiFacesis the number of faces in the VTF image (default 1).
uiSlicesis the number of z slices in the VTF image (default 1).
ImageFormatis the storage format of the main VTF image (default RGBA8888).
bThumbnailsets if the VTF image will contain an additional thumbnail (default true).
bMipmapssets if the VTF image will contain mipmaps (default true).
bNullImageDatasets if the image data should be zero'd out on creation (default false).
Returns
true on successful creation, otherwise false.
Note
Animated and static textures have 1 face. Cubemaps have 6, one for each side of the cube.
See Also
tagSVTFCreateOptions
vlBool CVTFFile::Create ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlByte lpImageDataRGBA8888,
const SVTFCreateOptions VTFCreateOptions 
)

Create a new VTF image from existing data.

Creates a new VTF image using image data already stored in memory. The existing image data should be stored in RGBA8888 format.

Parameters
uiWidthis the width in pixels of the main VTF image.
uiHeightis the height in pixels of the main VTF image.
lpImageDataRGBA8888is a pointer to the source RGBA8888 data.
VTFCreateOptionscontains the options for image creation.
Returns
true on successful creation, otherwise false.
See Also
tagSVTFCreateOptions
vlBool CVTFFile::Create ( vlUInt  uiWidth,
vlUInt  uiHeight,
vlUInt  uiFrames,
vlUInt  uiFaces,
vlUInt  vlSlices,
vlByte **  lpImageDataRGBA8888,
const SVTFCreateOptions VTFCreateOptions 
)

Create a new VTF multi-frame or cubemap image from existing data.

Creates a new multi-frame or cubemap VTF image using image data already stored in memory. The existing image data should be stored in RGBA8888 format.

Parameters
uiWidthis the width in pixels of the main VTF image.
uiHeightis the height in pixels of the main VTF image.
uiFramesis the number of frames in the VTF image.
uiFacesis the number of faces in the VTF image.
vlSlicesis the number of z slices in the VTF image.
lpImageDataRGBA8888is an array of pointers to the image data for each frame/face.
VTFCreateOptionscontains the options for image creation.
Returns
true on successful creation, otherwise false.
Note
Animated and static textures have 1 face. Cubemaps have 6, one for each side of the cube.
See Also
tagSVTFCreateOptions
vlBool CVTFFile::GenerateMipmaps ( VTFMipmapFilter  MipmapFilter = MIPMAP_FILTER_BOX,
VTFSharpenFilter  SharpenFilter = SHARPEN_FILTER_NONE 
)

Generate MIP maps from the main image data.

Generates MIP maps for the image down to 1 x 1 pixel using the data in MIP level 0 as the source. Unless otherwise specified, a standard box filter with no sharpening is used during compression.

Parameters
MipmapFilteris the reduction filter to use (default Box).
SharpenFilteris the sharpening filter to use (default none).
Returns
true on sucessful creation, otherwise false.
vlBool CVTFFile::GenerateMipmaps ( vlUInt  uiFace,
vlUInt  uiFrame,
VTFMipmapFilter  MipmapFilter = MIPMAP_FILTER_BOX,
VTFSharpenFilter  SharpenFilter = SHARPEN_FILTER_NONE 
)

Generate MIP maps from a specific face and frame.

Generates MIP maps for the image down to 1 x 1 pixel using the data in the given face and frame as the source. Unless otherwise specified, a standard box filter with no sharpening is used during compression.

Parameters
uiFaceis the face index to use.
uiFrameis the frame index to use.
MipmapFilteris the reduction filter to use (default Box).
SharpenFilteris the sharpening filter to use (default none).
Note
Frames start at index 0 for the first frame. Faces start at index 0 for the first face. Cubemaps have 6 faces, others only 1.
Returns
true on sucessful creation, otherwise false.
vlBool CVTFFile::GenerateNormalMap ( VTFKernelFilter  KernelFilter = KERNEL_FILTER_3X3,
VTFHeightConversionMethod  HeightConversionMethod = HEIGHT_CONVERSION_METHOD_AVERAGE_RGB,
VTFNormalAlphaResult  NormalAlphaResult = NORMAL_ALPHA_RESULT_WHITE 
)

Convert image to a normal map.

Converts the image to a normal map using the image data in MIP level 0 as the source.

Parameters
KernelFilteris the kernel filter to use (default 3x3).
HeightConversionMethodis the method of determining the height data from the source (default average RGB).
NormalAlphaResultis how the alpha channel should be handled post processing (defaul make 100% opaque).
Returns
true on sucessful creation, otherwise false.
Note
The options for conversion are the same used in the nVidea NormalMap Photoshop plug-in.
vlBool CVTFFile::GenerateNormalMap ( vlUInt  uiFrame,
VTFKernelFilter  KernelFilter = KERNEL_FILTER_3X3,
VTFHeightConversionMethod  HeightConversionMethod = HEIGHT_CONVERSION_METHOD_AVERAGE_RGB,
VTFNormalAlphaResult  NormalAlphaResult = NORMAL_ALPHA_RESULT_WHITE 
)

Convert image to a normal map from a specific frame.

Converts the image to a normal map using the image data in the given frame as the source.

Parameters
uiFrameis the frame index to use.
KernelFilteris the kernel filter to use (default 3x3).
HeightConversionMethodis the method of determining the height data from the source (default average RGB).
NormalAlphaResultis how the alpha channel should be handled post processing (defaul make 100% opaque).
Returns
true on sucessful creation, otherwise false.
Note
The options for conversion are the same used in the nVidea NormalMap Photoshop plug-in.
vlBool CVTFFile::GenerateThumbnail ( )

Generate a thumbnail image.

Generates the thumbnail image for the VTF image by copying an existing MIP map of the right size and converting it to the required format.

Returns
true on sucessful creation, otherwise false.
See Also
SetThumbnailData()
vlByte * CVTFFile::GetData ( vlUInt  uiFrame,
vlUInt  uiFace,
vlUInt  uiSlice,
vlUInt  uiMipmapLevel 
) const

Get a pointer to the image data for a specific image.

Returns a pointer to the image data for a given frame, face and MIP level.

Parameters
uiFrameis the desired frame.
uiFaceis the desired face.
uiSliceis the desired z slice.
uiMipmapLevelis the desired MIP level.
Note
Frames start at index 0 for the first frame. Faces start at index 0 for the first face. Cubemaps have 6 faces, others only 1. MIP levels start at index 0 for the largest image moving down in size.
See Also
GetFormat()
vlBool CVTFFile::GetFlag ( VTFImageFlag  ImageFlag) const

Check if a specific flag is set in the VTF header.

Checks to see if the given flag is set in the VTF header struct.

Parameters
ImageFlagis the flag you wish to check for.
Returns
true if the flag is set, otherwise false.
vlBool CVTFFile::GetHasImage ( ) const

Check if image data has been loaded.

Check to see if the image buffer has data in it. If a VTF file was loaded into the class with the bHeaderOnly option, this will return false.

Returns
true if image data is present, otherwise false.
SVTFImageFormatInfo const & CVTFFile::GetImageFormatInfo ( VTFImageFormat  ImageFormat)
static

Get VTFImageFormat info.

Returns a SImageFormatInfo info struct for the specified VTFImageFormat.

Parameters
ImageFormatis the format to get info on.
Returns
SImageFormatInfo info struct.
vlVoid CVTFFile::GetReflectivity ( vlSingle sX,
vlSingle sY,
vlSingle sZ 
) const

Get the reflectivity values.

Get the reflectivity value for each vector axis from the VTF header.

Parameters
sX,sY,sZare the variables to hold the values reflectivity vector.
vlVoid * CVTFFile::GetResourceData ( vlUInt  uiType,
vlUInt uiSize 
) const

Get a VTF resource type's data.

Checks to see if the resource type exists and returns it's data.

Parameters
uiTypeis the resource type to retrieve.
uiSizeis the size of the resource data.
Returns
a pointer to the resource data buffer if the resource exists.
vlByte * CVTFFile::GetThumbnailData ( ) const

Get a pointer to the thumbnail image data for the current image.

Returns a pointer to the thumbnail image data for the current image.

Returns
vlByte pointer to the image data.
See Also
GetThumbnailFormat()
vlBool CVTFFile::IsLoaded ( ) const

Check if a VTFFile image is loaded or valid.

Checks if a file was loaded or a new image was created correctly by checking for the existance of a valid header struct in the VTFFile class.

Returns
true if header is valid, otherwise false.
See Also
Create()
vlBool CVTFFile::Load ( const vlChar cFileName,
vlBool  bHeaderOnly = vlFalse 
)

Loads a VTF image from disk.

Loads a VTF image file from disk into the current VTFFile class. You may choose to load just the header only if you want to get info about the file and save memory.

Parameters
cFileNameis the path and filename of the file to load.
bHeaderOnlysets whether to load just the VTF header or not (default false).
Returns
true on sucessful load, otherwise false.
vlBool CVTFFile::Load ( const vlVoid lpData,
vlSize  uiBufferSize,
vlBool  bHeaderOnly = vlFalse 
)

Loads a VTF image from memory.

Loads a VTF image file stored in memory into the current VTFFile class. You may choose to load just the header only if you want to get info about the file and save memory.

Parameters
lpDatais a pointer to the VTF file in memory.
uiBufferSizeis the size of the VTF file in bytes.
bHeaderOnlysets whether to load just the VTF header or not (default false).
Returns
true on sucessful load, otherwise false.
vlBool CVTFFile::Load ( vlVoid pUserData,
vlBool  bHeaderOnly = vlFalse 
)

Loads a VTF image using callback functions.

Loads a VTF image file into the current VTFFile class. You may choose to load just the header only if you want to get info about the file and save memory.

Parameters
pUserDatais a pointer to custom user data.
bHeaderOnlysets whether to load just the VTF header or not (default false).
Returns
true on sucessful load, otherwise false.
vlBool CVTFFile::Resize ( const vlByte lpSourceRGBA8888,
vlByte lpDestRGBA8888,
vlUInt  uiSourceWidth,
vlUInt  uiSourceHeight,
vlUInt  uiDestWidth,
vlUInt  uiDestHeight,
VTFMipmapFilter  ResizeFilter = MIPMAP_FILTER_TRIANGLE,
VTFSharpenFilter  SharpenFilter = SHARPEN_FILTER_NONE 
)
static

Re-sizes an image.

Re-sizes an image in RGBA8888 format to the given dimensions using the specified filters.

Parameters
lpSourceRGBA8888is a pointer to the source image data in RGBA8888 format.
lpDestRGBA8888is a pointer to the buffer for the converted data.
uiSourceWidthis the width of the source image in pixels.
uiSourceHeightis the height of the source image in pixels.
uiDestWidthis the width of the destination image in pixels.
uiDestHeightis the height of the destination image in pixels.
ResizeFilteris the image reduction filter to use (default triangle).
SharpenFilteris the image sharpening filter to use (default none).
Returns
true on sucessful re-size, otherwise false.
vlBool CVTFFile::Save ( const vlChar cFileName) const

Save a VTF image from disk.

Saves a VTF format image file to disk from the current VTFFile class.

Parameters
cFileNameis the path and filename of the file to load.
Returns
true on sucessful save, otherwise false.
vlBool CVTFFile::Save ( vlVoid lpData,
vlSize  uiBufferSize,
vlSize &  uiSize 
) const

Save a VTF image to memory.

Saves a VTF format image file to memory from the current VTFFile class.

Parameters
lpDatais a pointer to save the image to.
uiBufferSizeis the size of the buffer in bytes.
uiSizeis the size of VTF file in bytes as written into lpData.
Returns
true on sucessful save, otherwise false.
vlBool CVTFFile::Save ( vlVoid pUserData) const

Save a VTF image using callback functions.

Saves a VTF format image file from the current VTFFile class.

Parameters
pUserDatais a pointer to custom user data.
Returns
true on sucessful save, otherwise false.
vlVoid CVTFFile::SetBumpmapScale ( vlSingle  sBumpmapScale)

Set the bump scale value.

Sets the bump scale in the VTF header to the given floating point value.

Parameters
sBumpmapScaleis the scale value to set.
vlVoid CVTFFile::SetData ( vlUInt  uiFrame,
vlUInt  uiFace,
vlUInt  uiSlice,
vlUInt  uiMipmapLevel,
vlByte lpData 
)

Set the image data for a specific image.

Sets the image data for a given frame, face and MIP level. The source image data pointed to by lpData must be in the format specified in the VTF header.

Parameters
uiFrameis the desired frame.
uiFaceis the desired face.
uiSliceis the desired z slice.
uiMipmapLevelis the desired MIP level.
lpDatais a pointer to the image data.
Returns
vlByte pointer to the image data.
Note
Frames start at index 0 for the first frame. Faces start at index 0 for the first face. Cubemaps have 6 faces, others only 1. MIP levels start at index 0 for the largest image moving down in size.
See Also
GetFormat()
vlVoid CVTFFile::SetFlag ( VTFImageFlag  ImageFlag,
vlBool  bState 
)

Set the state of a specific flag in the VTF header.

Set the boolean state of the given flag in the VTF header struct.

Parameters
ImageFlagis the flag you wish to set.
bStateis the state you wish to set for the flag.
vlVoid CVTFFile::SetReflectivity ( vlSingle  sX,
vlSingle  sY,
vlSingle  sZ 
)

Set the reflectivity values.

Set the reflectivity value for each vector axis in the VTF header.

Parameters
sX,sY,sZare the values for each reflectivity vector axis.
vlVoid * CVTFFile::SetResourceData ( vlUInt  uiType,
vlUInt  uiSize,
vlVoid lpData 
)

Set a VTF resource type's data.

Set a resource type's data. If the type deson't exist, the resource is created. If uiSize is 0, the resource is deleted.

Parameters
uiTypeis the resource type to set.
uiSizeis the size of the resource data; if 0 the resource is deleted, otherwise if the resource does not have a data chunk this must be 4.
lpDatais the resource data; if null the resource data is zeroed.
Returns
a pointer to the resource data buffer if the resource exists or was created.
vlVoid CVTFFile::SetThumbnailData ( vlByte lpData)

Set the thumbnail image data for the current image.

Sets the thumbnail image data for the current image. The source image data pointed to by lpData must be in the format specified for the thumbnail in the VTF header.

Parameters
lpDatais a pointer to the image data.
See Also
GetThumbnailFormat()

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