Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
ImagePacker Class Reference

#include <ImagePacker.h>

Public Types

enum  { GAP_METHOD_EXTEND_RGB = 0x00000001 , GAP_METHOD_GUTTER = 0x00000002 }
 

Public Member Functions

 ImagePacker (void)
 
virtual ~ImagePacker (void)
 
Bool init (void)
 initialize the system
 
Bool process (void)
 run the process
 
Bool getSettingsFromDialog (HWND dialog)
 get the options for exection
 
void setWindowHandle (HWND hWnd)
 set window handle for 'dialog' app
 
HWND getWindowHandle (void)
 get window handle for 'dialog' app
 
ICoord2DgetTargetSize (void)
 get target size
 
Int getTargetWidth (void)
 get target width
 
Int getTargetHeight (void)
 bet target height
 
void statusMessage (char *message)
 set a status message
 
UnsignedInt getImageCount (void)
 get image count
 
ImageInfogetImage (Int index)
 get image
 
TexturePagegetFirstTexturePage (void)
 get first texture page
 
UnsignedInt getPageCount (void)
 get the count of texutre pages
 
void setTargetPreviewPage (Int page)
 set the target preview page to view
 
Int getTargetPreviewPage (void)
 get the target preview page to view
 
void setGutter (UnsignedInt size)
 set gutter size in pixels
 
UnsignedInt getGutter (void)
 get gutter size in pixels
 
void setGapMethod (UnsignedInt methodBit)
 set gap method option
 
void clearGapMethod (UnsignedInt methodBit)
 clear gap method option
 
UnsignedInt getGapMethod (void)
 get gap method option
 
void setOutputAlpha (Bool outputAlpha)
 set output alpha option
 
Bool getOutputAlpha (void)
 get output alpha option
 
void setPreviewWindow (HWND window)
 assign preview window handle
 
HWND getPreviewWindow (void)
 get the preview window handle
 
void setUseTexturePreview (Bool use)
 use the real image data in preview
 
Bool getUseTexturePreview (void)
 get texture preview option
 
void setINICreate (Bool create)
 set create INI file option
 
Bool createINIFile (void)
 get create INI option
 
char * getOutputFile (void)
 get output filename
 
char * getOutputDirectory (void)
 get output directory
 
void setCompressTextures (Bool compress)
 set compress textures option
 
Bool getCompressTextures (void)
 get compress textures option
 

Protected Member Functions

void setTargetSize (Int width, Int height)
 set the size of the output target image
 
Bool checkOutputDirectory (void)
 verify output directory is OK
 
void resetImageDirectoryList (void)
 clear the image directory list
 
void resetImageList (void)
 clear the image list
 
void resetPageList (void)
 clear the texture page list
 
void addDirectory (char *path, Bool subDirs)
 add directory to directory list
 
void addImagesInDirectory (char *dir)
 add all images from the specified directory
 
void addImage (char *path)
 add image to image list
 
Bool validateImages (void)
 validate that the loaded images can all be processed
 
Bool packImages (void)
 do the packing
 
void writeFinalTextures (void)
 write the packed textures
 
Bool generateINIFile (void)
 generate the INI file for this image set
 
TexturePagecreateNewTexturePage (void)
 create a new texture page
 
void sortImageList (void)
 sort the image list
 

Protected Attributes

HWND m_hWnd
 window handle for app
 
ICoord2D m_targetSize
 the target size
 
Bool m_useSubFolders
 use subfolders option
 
char m_outputFile [MAX_OUTPUT_FILE_LEN]
 output filename
 
char m_outputDirectory [_MAX_PATH]
 destination for texture files
 
ImageDirectorym_dirList
 the directory list
 
UnsignedInt m_dirCount
 length of dirList
 
UnsignedInt m_imagesInDirs
 number of images in all directories
 
ImageInfo ** m_imageList
 the image list
 
UnsignedInt m_imageCount
 length of imageList
 
char m_statusBuffer [1024]
 for printing status messages
 
TexturePagem_pageTail
 end of the texture page list
 
TexturePagem_pageList
 the final images generated from the packer
 
UnsignedInt m_pageCount
 length of page list
 
UnsignedInt m_gapMethod
 gap method option bits
 
UnsignedInt m_gutterSize
 gutter gaps between images in pixels
 
Bool m_outputAlpha
 final image files will have an alpha channel
 
Bool m_createINI
 create the INI file from compressed image data
 
Int m_targetPreviewPage
 preview page we're looking at
 
HWND m_hWndPreview
 the preview window
 
Bool m_showTextureInPreview
 show actual texture in preview window
 
Targam_targa
 targa for loading file headers
 
Bool m_compressTextures
 compress the final textures
 

Detailed Description

Definition at line 66 of file ImagePacker.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
GAP_METHOD_EXTEND_RGB 

extend RGB (no alpha) of image on all sides

GAP_METHOD_GUTTER 

put transparent gutter on right and bottom side of image

Definition at line 71 of file ImagePacker.h.

Constructor & Destructor Documentation

◆ ImagePacker()

ImagePacker::ImagePacker ( void )

Definition at line 1097 of file ImagePacker.cpp.

◆ ~ImagePacker()

ImagePacker::~ImagePacker ( void )
virtual

Definition at line 1132 of file ImagePacker.cpp.

Member Function Documentation

◆ addDirectory()

void ImagePacker::addDirectory ( char * path,
Bool subDirs )
protected

add directory to directory list

Add the directory to the directory list, do not add it if it is already in the directory list. We want to have that sanity check so that we can be assured that each image being added to the image list from each directory will be unique and we therefore don't have to do any further checking for duplicates

Definition at line 622 of file ImagePacker.cpp.

◆ addImage()

void ImagePacker::addImage ( char * path)
protected

add image to image list

Add the image to the image list

Definition at line 788 of file ImagePacker.cpp.

◆ addImagesInDirectory()

void ImagePacker::addImagesInDirectory ( char * dir)
protected

add all images from the specified directory

Add all the images in the specified directory

Definition at line 362 of file ImagePacker.cpp.

◆ checkOutputDirectory()

Bool ImagePacker::checkOutputDirectory ( void )
protected

verify output directory is OK

Verify that there are no files in the output directory ... if there are give the user the option to delete them, cancel the operation, or proceed with possibly overwriting any files there

Returns TRUE to proceed with the process, FALSE if the user wants to cancel the process

Definition at line 453 of file ImagePacker.cpp.

◆ clearGapMethod()

void ImagePacker::clearGapMethod ( UnsignedInt methodBit)
inline

clear gap method option

Definition at line 208 of file ImagePacker.h.

◆ createINIFile()

Bool ImagePacker::createINIFile ( void )
inline

get create INI option

Definition at line 202 of file ImagePacker.h.

◆ createNewTexturePage()

TexturePage * ImagePacker::createNewTexturePage ( void )
protected

create a new texture page

Create a new texture page and add to the list

Definition at line 77 of file ImagePacker.cpp.

◆ generateINIFile()

Bool ImagePacker::generateINIFile ( void )
protected

generate the INI file for this image set

Generate the INI image file definition for the final packed images

Definition at line 864 of file ImagePacker.cpp.

◆ getCompressTextures()

Bool ImagePacker::getCompressTextures ( void )
inline

get compress textures option

Definition at line 206 of file ImagePacker.h.

◆ getFirstTexturePage()

TexturePage * ImagePacker::getFirstTexturePage ( void )
inline

get first texture page

Definition at line 198 of file ImagePacker.h.

◆ getGapMethod()

UnsignedInt ImagePacker::getGapMethod ( void )
inline

get gap method option

Definition at line 209 of file ImagePacker.h.

◆ getGutter()

UnsignedInt ImagePacker::getGutter ( void )
inline

get gutter size in pixels

Definition at line 195 of file ImagePacker.h.

◆ getImage()

ImageInfo * ImagePacker::getImage ( Int index)
inline

get image

Definition at line 188 of file ImagePacker.h.

◆ getImageCount()

UnsignedInt ImagePacker::getImageCount ( void )
inline

get image count

Definition at line 187 of file ImagePacker.h.

◆ getOutputAlpha()

Bool ImagePacker::getOutputAlpha ( void )
inline

get output alpha option

Definition at line 197 of file ImagePacker.h.

◆ getOutputDirectory()

char * ImagePacker::getOutputDirectory ( void )
inline

get output directory

Definition at line 204 of file ImagePacker.h.

◆ getOutputFile()

char * ImagePacker::getOutputFile ( void )
inline

get output filename

Definition at line 203 of file ImagePacker.h.

◆ getPageCount()

UnsignedInt ImagePacker::getPageCount ( void )
inline

get the count of texutre pages

Definition at line 191 of file ImagePacker.h.

◆ getPreviewWindow()

HWND ImagePacker::getPreviewWindow ( void )
inline

get the preview window handle

Definition at line 193 of file ImagePacker.h.

◆ getSettingsFromDialog()

Bool ImagePacker::getSettingsFromDialog ( HWND dialog)

get the options for exection

Given the current state of the option dialog passed in, get all the settings we need for the image packer from the GUI and validate them

Definition at line 948 of file ImagePacker.cpp.

◆ getTargetHeight()

Int ImagePacker::getTargetHeight ( void )
inline

bet target height

Definition at line 184 of file ImagePacker.h.

◆ getTargetPreviewPage()

Int ImagePacker::getTargetPreviewPage ( void )
inline

get the target preview page to view

Definition at line 190 of file ImagePacker.h.

◆ getTargetSize()

ICoord2D * ImagePacker::getTargetSize ( void )
inline

get target size

Definition at line 182 of file ImagePacker.h.

◆ getTargetWidth()

Int ImagePacker::getTargetWidth ( void )
inline

get target width

Definition at line 183 of file ImagePacker.h.

◆ getUseTexturePreview()

Bool ImagePacker::getUseTexturePreview ( void )
inline

get texture preview option

Definition at line 200 of file ImagePacker.h.

◆ getWindowHandle()

HWND ImagePacker::getWindowHandle ( void )
inline

get window handle for 'dialog' app

Definition at line 186 of file ImagePacker.h.

◆ init()

Bool ImagePacker::init ( void )

initialize the system

Initialize the image packer system

Definition at line 1149 of file ImagePacker.cpp.

◆ packImages()

Bool ImagePacker::packImages ( void )
protected

do the packing

Pack all the images in the image list, starting from the top and working from there

Definition at line 195 of file ImagePacker.cpp.

◆ process()

Bool ImagePacker::process ( void )

run the process

Run the packing process

Definition at line 1181 of file ImagePacker.cpp.

◆ resetImageDirectoryList()

void ImagePacker::resetImageDirectoryList ( void )
protected

clear the image directory list

Clear the image directory list

Definition at line 584 of file ImagePacker.cpp.

◆ resetImageList()

void ImagePacker::resetImageList ( void )
protected

clear the image list

Clear the image list

Definition at line 605 of file ImagePacker.cpp.

◆ resetPageList()

void ImagePacker::resetPageList ( void )
protected

clear the texture page list

Clear the page list

Definition at line 562 of file ImagePacker.cpp.

◆ setCompressTextures()

void ImagePacker::setCompressTextures ( Bool compress)
inline

set compress textures option

Definition at line 205 of file ImagePacker.h.

◆ setGapMethod()

void ImagePacker::setGapMethod ( UnsignedInt methodBit)
inline

set gap method option

Definition at line 207 of file ImagePacker.h.

◆ setGutter()

void ImagePacker::setGutter ( UnsignedInt size)
inline

set gutter size in pixels

Definition at line 194 of file ImagePacker.h.

◆ setINICreate()

void ImagePacker::setINICreate ( Bool create)
inline

set create INI file option

Definition at line 201 of file ImagePacker.h.

◆ setOutputAlpha()

void ImagePacker::setOutputAlpha ( Bool outputAlpha)
inline

set output alpha option

Definition at line 196 of file ImagePacker.h.

◆ setPreviewWindow()

void ImagePacker::setPreviewWindow ( HWND window)
inline

assign preview window handle

Definition at line 192 of file ImagePacker.h.

◆ setTargetPreviewPage()

void ImagePacker::setTargetPreviewPage ( Int page)
inline

set the target preview page to view

Definition at line 189 of file ImagePacker.h.

◆ setTargetSize()

void ImagePacker::setTargetSize ( Int width,
Int height )
inlineprotected

set the size of the output target image

Definition at line 181 of file ImagePacker.h.

◆ setUseTexturePreview()

void ImagePacker::setUseTexturePreview ( Bool use)
inline

use the real image data in preview

Definition at line 199 of file ImagePacker.h.

◆ setWindowHandle()

void ImagePacker::setWindowHandle ( HWND hWnd)
inline

set window handle for 'dialog' app

Definition at line 185 of file ImagePacker.h.

◆ sortImageList()

void ImagePacker::sortImageList ( void )
protected

sort the image list

Sort the image list

Definition at line 351 of file ImagePacker.cpp.

◆ statusMessage()

void ImagePacker::statusMessage ( char * message)

set a status message

Status message for the program

Definition at line 1171 of file ImagePacker.cpp.

◆ validateImages()

Bool ImagePacker::validateImages ( void )
protected

validate that the loaded images can all be processed

Check all the images in the image list, if any of them cannot be processed we will flag them as so. If we have some images that can't be processed, we will warn the user of these images and ask them whether or not to proceed.

Returns TRUE to proceed Returns FALSE to cancel build

Definition at line 122 of file ImagePacker.cpp.

◆ writeFinalTextures()

void ImagePacker::writeFinalTextures ( void )
protected

write the packed textures

Generate and write the final textures to the output directory of the packed images along with a definition file for which images are where on the page

Definition at line 273 of file ImagePacker.cpp.

Member Data Documentation

◆ m_compressTextures

Bool ImagePacker::m_compressTextures
protected

compress the final textures

Definition at line 174 of file ImagePacker.h.

◆ m_createINI

Bool ImagePacker::m_createINI
protected

create the INI file from compressed image data

Definition at line 167 of file ImagePacker.h.

◆ m_dirCount

UnsignedInt ImagePacker::m_dirCount
protected

length of dirList

Definition at line 156 of file ImagePacker.h.

◆ m_dirList

ImageDirectory* ImagePacker::m_dirList
protected

the directory list

Definition at line 155 of file ImagePacker.h.

◆ m_gapMethod

UnsignedInt ImagePacker::m_gapMethod
protected

gap method option bits

Definition at line 164 of file ImagePacker.h.

◆ m_gutterSize

UnsignedInt ImagePacker::m_gutterSize
protected

gutter gaps between images in pixels

Definition at line 165 of file ImagePacker.h.

◆ m_hWnd

HWND ImagePacker::m_hWnd
protected

window handle for app

Definition at line 149 of file ImagePacker.h.

◆ m_hWndPreview

HWND ImagePacker::m_hWndPreview
protected

the preview window

Definition at line 170 of file ImagePacker.h.

◆ m_imageCount

UnsignedInt ImagePacker::m_imageCount
protected

length of imageList

Definition at line 159 of file ImagePacker.h.

◆ m_imageList

ImageInfo** ImagePacker::m_imageList
protected

the image list

Definition at line 158 of file ImagePacker.h.

◆ m_imagesInDirs

UnsignedInt ImagePacker::m_imagesInDirs
protected

number of images in all directories

Definition at line 157 of file ImagePacker.h.

◆ m_outputAlpha

Bool ImagePacker::m_outputAlpha
protected

final image files will have an alpha channel

Definition at line 166 of file ImagePacker.h.

◆ m_outputDirectory

char ImagePacker::m_outputDirectory[_MAX_PATH]
protected

destination for texture files

Definition at line 153 of file ImagePacker.h.

◆ m_outputFile

char ImagePacker::m_outputFile[MAX_OUTPUT_FILE_LEN]
protected

output filename

Definition at line 152 of file ImagePacker.h.

◆ m_pageCount

UnsignedInt ImagePacker::m_pageCount
protected

length of page list

Definition at line 163 of file ImagePacker.h.

◆ m_pageList

TexturePage* ImagePacker::m_pageList
protected

the final images generated from the packer

Definition at line 162 of file ImagePacker.h.

◆ m_pageTail

TexturePage* ImagePacker::m_pageTail
protected

end of the texture page list

Definition at line 161 of file ImagePacker.h.

◆ m_showTextureInPreview

Bool ImagePacker::m_showTextureInPreview
protected

show actual texture in preview window

Definition at line 171 of file ImagePacker.h.

◆ m_statusBuffer

char ImagePacker::m_statusBuffer[1024]
protected

for printing status messages

Definition at line 160 of file ImagePacker.h.

◆ m_targa

Targa* ImagePacker::m_targa
protected

targa for loading file headers

Definition at line 173 of file ImagePacker.h.

◆ m_targetPreviewPage

Int ImagePacker::m_targetPreviewPage
protected

preview page we're looking at

Definition at line 169 of file ImagePacker.h.

◆ m_targetSize

ICoord2D ImagePacker::m_targetSize
protected

the target size

Definition at line 150 of file ImagePacker.h.

◆ m_useSubFolders

Bool ImagePacker::m_useSubFolders
protected

use subfolders option

Definition at line 151 of file ImagePacker.h.


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