VTFLib::CVTFFile Class Reference

VTF File access/creation class. More...

#include <VTFFile.h>

Collaboration diagram for VTFLib::CVTFFile:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CVTFFile ()
 Default constructor.
 CVTFFile (const CVTFFile &VTFFile)
 Create a new VTFFile class as a copy of another.
 CVTFFile (const CVTFFile &VTFFile, VTFImageFormat ImageFormat)
 Create a new VTFFile class as a duplicate of another.
 ~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..
vlBool Create (vlUInt uiWidth, vlUInt uiHeight, vlByte *lpImageDataRGBA8888, const SVTFCreateOptions &VTFCreateOptions)
 Create a new VTF image from existing data.
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.
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.
vlBool Load (const vlChar *cFileName, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image from disk.
vlBool Load (const vlVoid *lpData, vlUInt uiBufferSize, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image from memory.
vlBool Load (vlVoid *pUserData, vlBool bHeaderOnly=vlFalse)
 Loads a VTF image using callback functions.
vlBool Save (const vlChar *cFileName) const
 Save a VTF image from disk.
vlBool Save (vlVoid *lpData, vlUInt uiBufferSize, vlUInt &uiSize) const
 Save a VTF image to memory.
vlBool Save (vlVoid *pUserData) const
 Save a VTF image using callback functions.
vlBool GetHasImage () const
 Check if image data has been loaded.
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.
vlVoid SetFlag (VTFImageFlag ImageFlag, vlBool bState)
 Set the state of a specific flag in the VTF header.
vlSingle GetBumpmapScale () const
 Get the bump scale value.
vlVoid SetBumpmapScale (vlSingle sBumpmapScale)
 Set the bump scale value.
vlVoid GetReflectivity (vlSingle &sX, vlSingle &sY, vlSingle &sZ) const
 Get the reflectivity values.
vlVoid SetReflectivity (vlSingle sX, vlSingle sY, vlSingle sZ)
 Set the reflectivity values.
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.
vlVoid SetData (vlUInt uiFrame, vlUInt uiFace, vlUInt uiSlice, vlUInt uiMipmapLevel, vlByte *lpData)
 Set the image data for a specific image.
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.
vlVoid SetThumbnailData (vlByte *lpData)
 Set the thumbnail image data for the current image.
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.
vlVoidSetResourceData (vlUInt uiType, vlUInt uiSize, vlVoid *lpData)
 Set a VTF resource type's data.
vlBool GenerateMipmaps (VTFMipmapFilter MipmapFilter=MIPMAP_FILTER_BOX, VTFSharpenFilter SharpenFilter=SHARPEN_FILTER_NONE)
 Generate MIP maps from the main image data.
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.
vlBool GenerateThumbnail ()
 Generate a thumbnail image.
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.
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.
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.
static vlUInt ComputeImageSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, VTFImageFormat ImageFormat)
 Calculate data buffer size for an image.
static vlUInt ComputeImageSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, vlUInt uiMipmaps, VTFImageFormat ImageFormat)
 Calculate data buffer size for an image with MIP maps.
static vlUInt ComputeMipmapCount (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth)
 Compute the number of MIP maps needed by an image.
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.
static vlUInt ComputeMipmapSize (vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDepth, vlUInt uiMipmapLevel, VTFImageFormat ImageFormat)
 Compute how much memory a specific MIP map level needs.
static vlBool ConvertToRGBA8888 (vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat SourceFormat)
 Convert an image to RGBA8888 format.
static vlBool ConvertFromRGBA8888 (vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat DestFormat)
 Convert an image from RGBA8888 format.
static vlBool Convert (vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat SourceFormat, VTFImageFormat DestFormat)
 Convert an image from any format to any format.
static vlBool ConvertToNormalMap (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.
static vlBool Resize (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.
static vlVoid CorrectImageGamma (vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight, vlSingle sGammaCorrection)
 Correct and images gamma.
static vlVoid ComputeImageReflectivity (vlByte *lpImageDataRGBA8888, vlUInt uiWidth, vlUInt uiHeight, vlSingle &sX, vlSingle &sY, vlSingle &sZ)
 Computes the reflectivity for an image.
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.

Private Member Functions

vlBool IsPowerOfTwo (vlUInt uiSize)
vlUInt NextPowerOfTwo (vlUInt uiSize)
vlVoid ComputeResources ()
 Computes header VTF directory resources.
vlBool Load (IO::Readers::IReader *Reader, vlBool bHeaderOnly)
vlBool Save (IO::Writers::IWriter *Writer) const
vlUInt ComputeDataOffset (vlUInt uiFrame, vlUInt uiFace, vlUInt uiSlice, vlUInt uiMipmapLevel, VTFImageFormat ImageFormat) const

Static Private Member Functions

static vlBool DecompressDXT1 (vlByte *src, vlByte *dst, vlUInt uiWidth, vlUInt uiHeight)
static vlBool DecompressDXT3 (vlByte *src, vlByte *dst, vlUInt uiWidth, vlUInt uiHeight)
static vlBool DecompressDXT5 (vlByte *src, vlByte *dst, vlUInt uiWidth, vlUInt uiHeight)
static vlBool CompressDXTn (vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUInt uiHeight, VTFImageFormat DestFormat)

Private Attributes

SVTFHeaderHeader
vlUInt uiImageBufferSize
vlBytelpImageData
vlUInt uiThumbnailBufferSize
vlBytelpThumbnailImageData


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 (  ) 

Default constructor.

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:
VTFFile is 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:
VTFFile is the CVTFFile class you want to copy.
ImageFormat the format you want to convert the copied image data to.

CVTFFile::~CVTFFile (  ) 

Deconstructor.


Member Function Documentation

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:
uiWidth is the width in pixels of the main VTF image.
uiHeight is the height in pixels of the main VTF image.
uiFrames is the number of frames in the VTF image (default 1).
uiFaces is the number of faces in the VTF image (default 1).
uiSlices is the number of z slices in the VTF image (default 1).
ImageFormat is the storage format of the main VTF image (default RGBA8888).
bThumbnail sets if the VTF image will contain an additional thumbnail (default true).
bNullImageData sets 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:
uiWidth is the width in pixels of the main VTF image.
uiHeight is the height in pixels of the main VTF image.
lpImageDataRGBA8888 is a pointer to the source RGBA8888 data.
VTFCreateOptions contains 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:
uiWidth is the width in pixels of the main VTF image.
uiHeight is the height in pixels of the main VTF image.
uiFrames is the number of frames in the VTF image.
uiFaces is the number of faces in the VTF image.
vlSlices is the number of z slices in the VTF image.
lpImageDataRGBA8888 is an array of pointers to the image data for each frame/face.
VTFCreateOptions contains 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

vlVoid CVTFFile::Destroy (  ) 

Destroys the current VTF image by setting the header, thumbnail and image data to zero.

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:
cFileName is the path and filename of the file to load.
bHeaderOnly sets whether to load just the VTF header or not (default false).
Returns:
true on sucessful load, otherwise false.

vlBool CVTFFile::Load ( const vlVoid lpData,
vlUInt  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:
lpData is a pointer to the VTF file in memory.
uiBufferSize is the size of the VTF file in bytes.
bHeaderOnly sets 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:
pUserData is a pointer to custom user data.
bHeaderOnly sets whether to load just the VTF header or not (default false).
Returns:
true on sucessful load, 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:
cFileName is the path and filename of the file to load.
Returns:
true on sucessful save, otherwise false.

vlBool CVTFFile::Save ( vlVoid lpData,
vlUInt  uiBufferSize,
vlUInt uiSize 
) const

Save a VTF image to memory.

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

Parameters:
lpData is a pointer to save the image to.
uiBufferSize is the size of the VTF file in bytes.
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:
pUserData is a pointer to custom user data.
Returns:
true on sucessful save, otherwise false.

vlBool CVTFFile::IsPowerOfTwo ( vlUInt  uiSize  )  [private]

vlUInt CVTFFile::NextPowerOfTwo ( vlUInt  uiSize  )  [private]

vlVoid CVTFFile::ComputeResources (  )  [private]

Computes header VTF directory resources.

vlBool CVTFFile::Load ( IO::Readers::IReader Reader,
vlBool  bHeaderOnly 
) [private]

vlBool CVTFFile::Save ( IO::Writers::IWriter Writer  )  const [private]

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.

vlUInt CVTFFile::GetMajorVersion (  )  const

Returns the VTF file major version number.

vlUInt CVTFFile::GetMinorVersion (  )  const

Returns the VTF file minor version number.

vlUInt CVTFFile::GetSize (  )  const

Returns the VTF file size in bytes.

vlUInt CVTFFile::GetWidth (  )  const

Returns the width of the image in pixels from the VTF header.

vlUInt CVTFFile::GetHeight (  )  const

Returns the height of the image in pixels from the VTF header.

vlUInt CVTFFile::GetDepth (  )  const

Returns the depth of the image in pixels from the VTF header.

vlUInt CVTFFile::GetFrameCount (  )  const

Returns the frame count from the VTF header.

vlUInt CVTFFile::GetFaceCount (  )  const

Returns the face count from the VTF header.

vlUInt CVTFFile::GetMipmapCount (  )  const

Returns the number of MIP levels in the image from the VTF header.

vlUInt CVTFFile::GetStartFrame (  )  const

Returns the start frame from the VTF header.

vlVoid CVTFFile::SetStartFrame ( vlUInt  uiStartFrame  ) 

Sets the start frame in the VTF header.

vlUInt CVTFFile::GetFlags (  )  const

Returns the image flags from the VTF header.

vlVoid CVTFFile::SetFlags ( vlUInt  uiFlags  ) 

Sets the image flags in the VTF header.

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:
ImageFlag is the flag you wish to check for.
Returns:
true if the flag is set, otherwise false.

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:
ImageFlag is the flag you wish to set.
bState is the state you wish to set for the flag.

vlSingle CVTFFile::GetBumpmapScale (  )  const

Get the bump scale value.

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:
sBumpmapScale is the scale value to set.

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,sZ are the variables to hold the values reflectivity vector.

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,sZ are the values for each reflectivity vector axis.

VTFImageFormat CVTFFile::GetFormat (  )  const

Returns the storage format of the main image data set in the VTF header.

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:
uiFrame is the desired frame.
uiFace is the desired face.
uiSlice is the desired z slice.
uiMipmapLevel is 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()

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:
uiFrame is the desired frame.
uiFace is the desired face.
uiSlice is the desired z slice.
uiMipmapLevel is the desired MIP level.
lpData is 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()

vlBool CVTFFile::GetHasThumbnail (  )  const

Returns if a the current VTF image image contains a thumbnail version.

vlUInt CVTFFile::GetThumbnailWidth (  )  const

Returns the width in pixels of the current images thumbnail.

vlUInt CVTFFile::GetThumbnailHeight (  )  const

Returns the heught in pixels of the current images thumbnail.

VTFImageFormat CVTFFile::GetThumbnailFormat (  )  const

Returns the image format of the current images thumbnail.

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()

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:
lpData is a pointer to the image data.
See also:
GetThumbnailFormat()

vlBool CVTFFile::GetSupportsResources (  )  const

Returns true if the current VTF file version supports resources.

vlUInt CVTFFile::GetResourceCount (  )  const

Returns the number of resources contained within the VTF file.

vlUInt CVTFFile::GetResourceType ( vlUInt  uiIndex  )  const

Returns the resource type;.

vlBool CVTFFile::GetHasResource ( vlUInt  uiType  )  const

Returns true if the resource exists.

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:
uiType is the resource type to retrieve.
uiSize is the size of the resource data.
Returns:
a pointer to the resource data buffer if the resource exists.

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:
uiType is the resource type to set.
uiSize is 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.
lpData is 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.

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:
MipmapFilter is the reduction filter to use (default Box).
SharpenFilter is 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:
uiFace is the face index to use.
uiFrame is the frame index to use.
MipmapFilter is the reduction filter to use (default Box).
SharpenFilter is 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::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()

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:
KernelFilter is the kernel filter to use (default 3x3).
HeightConversionMethod is the method of determining the height data from the source (default average RGB).
NormalAlphaResult is 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:
uiFrame is the frame index to use.
KernelFilter is the kernel filter to use (default 3x3).
HeightConversionMethod is the method of determining the height data from the source (default average RGB).
NormalAlphaResult is 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::GenerateSphereMap (  ) 

Creates a spheremap from using the 6 faces of the image making up its cubemap.

vlBool CVTFFile::ComputeReflectivity (  ) 

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

SVTFImageFormatInfo const & CVTFFile::GetImageFormatInfo ( VTFImageFormat  ImageFormat  )  [static]

Get VTFImageFormat info.

Returns a SImageFormatInfo info struct for the specified VTFImageFormat.

Parameters:
ImageFormat is the format to get info on.
Returns:
SImageFormatInfo info struct.

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:
uiWidth is the width in pixels of the largest MIP level.
uiHeight is the height in pixels of the largest MIP level.
uiDepth is the depth in pixels of the largest MIP level.
ImageFormat is 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:
uiWidth is the width in pixels of the largest MIP level.
uiHeight is the height in pixels of the largest MIP level.
uiDepth is the depth in pixels of the largest MIP level.
uiMipmaps is the number of MIP maps to include in the calculation starting with the largest.
ImageFormat is 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:
uiWidth is the width in pixels of the original image.
uiHeight is the height in pixels of the original image.
uiDepth is 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:
uiWidth is the width in pixels of the largest MIP level.
uiHeight is the height in pixels of the largest MIP level.
uiDepth is the depth in pixels of the largest MIP level.
uiMipmapLevel is the MIP level you want the dimensions of.
uiMipmapWidth is the variable to hold the calculated width.
uiMipmapHeight is the variable to hold the calculated height.
uiMipmapDepth is 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:
uiWidth is the width in pixels of the source image.
uiHeight is the height in pixels of the source image.
uiDepth is the depth in pixels of the source image.
uiMipmapLevel is the MIP level you want the size of.
ImageFormat is the image format the MIP map image data is stored in.
Returns:
size of the MIP map image data in bytes.

vlUInt CVTFFile::ComputeDataOffset ( vlUInt  uiFrame,
vlUInt  uiFace,
vlUInt  uiSlice,
vlUInt  uiMipmapLevel,
VTFImageFormat  ImageFormat 
) const [private]

vlBool CVTFFile::ConvertToRGBA8888 ( 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:
lpSource is a pointer to the source image data.
lpDest is a pointer to the buffer for the converted data.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
SourceFormat is the image format of the source data.
Returns:
true on sucessful conversion, otherwise false.

vlBool CVTFFile::ConvertFromRGBA8888 ( 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:
lpSource is a pointer to the source image data in RGBA8888 format.
lpDest is a pointer to the buffer for the converted data.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
DestFormat is the image format you wish to convert to.
Returns:
true on sucessful conversion, otherwise false.

vlBool CVTFFile::Convert ( 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:
lpSource is a pointer to the source image data.
lpDest is a pointer to the buffer for the converted data.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
SourceFormat is the image format you are converting from.
DestFormat is the image format you wish to convert to.
Returns:
true on sucessful conversion, otherwise false.

vlBool CVTFFile::ConvertToNormalMap ( 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:
lpSourceRGBA8888 is a pointer to the source image data in RGBA8888 format.
lpDestRGBA8888 is a pointer to the buffer for the converted data.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
KernelFilter is the kernel filter to use (default 3x3).
HeightConversionMethod is the method of determining the height data from the source (default average RGB).
NormalAlphaResult is how the alpha channel should be handled post processing (defaul make 100% opaque).
bMinimumZ is the minimum normal Z value (default 0).
sScale is the normal map height scale (default 2).
bWrap sets whether the normal map should be tileable (default false).
bInvertX sets if the normal map should be flipped along its X axis (default false).
bInvertY sets if the normal map should be flipped along its Y axis (default false).
Returns:
true on sucessful conversion, otherwise false.

vlBool CVTFFile::Resize ( 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:
lpSourceRGBA8888 is a pointer to the source image data in RGBA8888 format.
lpDestRGBA8888 is a pointer to the buffer for the converted data.
uiSourceWidth is the width of the source image in pixels.
uiSourceHeight is the height of the source image in pixels.
uiDestWidth is the width of the destination image in pixels.
uiDestHeight is the height of the destination image in pixels.
ResizeFilter is the image reduction filter to use (default triangle).
SharpenFilter is the image sharpening filter to use (default none).
Returns:
true on sucessful re-size, otherwise false.

vlBool CVTFFile::DecompressDXT1 ( vlByte src,
vlByte dst,
vlUInt  uiWidth,
vlUInt  uiHeight 
) [static, private]

vlBool CVTFFile::DecompressDXT3 ( vlByte src,
vlByte dst,
vlUInt  uiWidth,
vlUInt  uiHeight 
) [static, private]

vlBool CVTFFile::DecompressDXT5 ( vlByte src,
vlByte dst,
vlUInt  uiWidth,
vlUInt  uiHeight 
) [static, private]

vlBool CVTFFile::CompressDXTn ( vlByte lpSource,
vlByte lpDest,
vlUInt  uiWidth,
vlUInt  uiHeight,
VTFImageFormat  DestFormat 
) [static, private]

vlVoid CVTFFile::CorrectImageGamma ( vlByte lpImageDataRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight,
vlSingle  sGammaCorrection 
) [static]

Correct and images gamma.

Applies gamma correction to an image.

Parameters:
lpImageDataRGBA8888 is a pointer to the image data in RGBA8888 format.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
sGammaCorrection is the amount of gamma correction to apply.

vlVoid CVTFFile::ComputeImageReflectivity ( 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:
lpImageDataRGBA8888 is a pointer to the image data in RGBA8888 format.
uiWidth is the width of the source image in pixels.
uiHeight is the height of the source image in pixels.
sX,sY,sZ are the variables to hold the values reflectivity vector.
See also:
ComputeReflectivity()

GetReflectivity()

SetReflectivity()

vlVoid CVTFFile::FlipImage ( vlByte lpImageDataRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight 
) [static]

Flips an image vertically along its X-axis.

vlVoid CVTFFile::MirrorImage ( vlByte lpImageDataRGBA8888,
vlUInt  uiWidth,
vlUInt  uiHeight 
) [static]

Flips an image horizontally along its Y-axis.


Member Data Documentation

SVTFHeader* VTFLib::CVTFFile::Header [private]

vlUInt VTFLib::CVTFFile::uiImageBufferSize [private]

vlByte* VTFLib::CVTFFile::lpImageData [private]

vlUInt VTFLib::CVTFFile::uiThumbnailBufferSize [private]

vlByte* VTFLib::CVTFFile::lpThumbnailImageData [private]


The documentation for this class was generated from the following files:
Generated on Fri Dec 28 23:26:23 2007 for VTFLib 1.2.7 by  doxygen 1.5.4