Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.
This commit is contained in:
parent
2e338c00cb
commit
3d0ee53a05
6072 changed files with 2283311 additions and 0 deletions
87
GeneralsMD/Code/Tools/ImagePacker/Include/ImageDirectory.h
Normal file
87
GeneralsMD/Code/Tools/ImagePacker/Include/ImageDirectory.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: ImageDirectory.h /////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: ImageDirectory.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: Image directory description for directories containing
|
||||
// image files to pack
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __IMAGEDIRECTORY_H_
|
||||
#define __IMAGEDIRECTORY_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
|
||||
// ImageDirectory -------------------------------------------------------------
|
||||
/** Directory to contain art files */
|
||||
//-----------------------------------------------------------------------------
|
||||
class ImageDirectory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
ImageDirectory();
|
||||
~ImageDirectory();
|
||||
|
||||
char *m_path; ///< path for directory
|
||||
UnsignedInt m_imageCount; ///< images to consider in this directory
|
||||
ImageDirectory *m_next;
|
||||
ImageDirectory *m_prev;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline ImageDirectory::~ImageDirectory( void ) { delete m_path; }
|
||||
inline ImageDirectory::ImageDirectory( void )
|
||||
{
|
||||
m_path = NULL;
|
||||
m_next = NULL;
|
||||
m_prev = NULL;
|
||||
m_imageCount = 0;
|
||||
}
|
||||
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // __IMAGEDIRECTORY_H_
|
||||
|
116
GeneralsMD/Code/Tools/ImagePacker/Include/ImageInfo.h
Normal file
116
GeneralsMD/Code/Tools/ImagePacker/Include/ImageInfo.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: ImageInfo.h //////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: ImageInfo.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: Image descriptor for the image packer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __IMAGEINFO_H_
|
||||
#define __IMAGEINFO_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
#include "Lib/BaseType.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class TexturePage;
|
||||
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
|
||||
// ImageInfo ------------------------------------------------------------------
|
||||
/** Image file information */
|
||||
//-----------------------------------------------------------------------------
|
||||
class ImageInfo
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
UNPACKED = 0x00000001, ///< this image has not yet been packed
|
||||
PACKED = 0x00000002, ///< this image has been packed and is done
|
||||
TOOBIG = 0x00000004, ///< this image was too big to process
|
||||
ROTATED90C = 0x00000008, ///< image is fitted after 90 clockwise rotation
|
||||
CANTPROCESS = 0x00000010, ///< can't be processed
|
||||
INVALIDCOLORDEPTH = 0x00000020, ///< unsupported source image format
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FIT_XGUTTER = 0x00000001, ///< x gutter is present in fit region
|
||||
FIT_YGUTTER = 0x00000002, ///< y gutter is present in fit region
|
||||
FIT_XBORDER_RIGHT = 0x00000004, ///< x border of 1 pixel on right side of region
|
||||
FIT_XBORDER_LEFT = 0x00000008, ///< x border of 1 pixel on left side of region
|
||||
FIT_YBORDER_TOP = 0x00000010, ///< y border of 1 pixel on top of region
|
||||
FIT_YBORDER_BOTTOM = 0x00000020, ///< y border of 1 pixel on bottom of image
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
ImageInfo();
|
||||
~ImageInfo();
|
||||
|
||||
char *m_path; ///< path to file
|
||||
char *m_filenameOnly; ///< filename with extension only (no path information)
|
||||
char *m_filenameOnlyNoExt; ///< filename without extension and no path info
|
||||
Int m_colorDepth; ///< bits per pixel
|
||||
UnsignedInt m_area; ///< width and height area
|
||||
ICoord2D m_size; ///< width and height of image
|
||||
UnsignedInt m_status; ///< status bits for image
|
||||
|
||||
TexturePage *m_page; ///< pointer to page this image is now packed on
|
||||
ImageInfo *m_nextPageImage; ///< next image on texture page
|
||||
ImageInfo *m_prevPageImage; ///< previous image on texture page
|
||||
IRegion2D m_pagePos; /** once placed on a texture page this has the
|
||||
coords of the image on the page, it does not include
|
||||
any padding from stretching borders and gutters */
|
||||
|
||||
UnsignedInt m_fitBits; /**< bit flags of the region used to fit this image on
|
||||
a page and therefore to create m_pagePos */
|
||||
ICoord2D m_gutterUsed; ///< the gutter size actually used in this image fit
|
||||
|
||||
};
|
||||
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // __IMAGEINFO_H_
|
||||
|
217
GeneralsMD/Code/Tools/ImagePacker/Include/ImagePacker.h
Normal file
217
GeneralsMD/Code/Tools/ImagePacker/Include/ImagePacker.h
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: ImagePacker.h ////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: ImagePacker.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: Image packer tool
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __IMAGEPACKER_H_
|
||||
#define __IMAGEPACKER_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
#include <windows.h>
|
||||
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
#include "Lib/BaseType.h"
|
||||
#include "WWLib/Targa.h"
|
||||
#include "ImageDirectory.h"
|
||||
#include "ImageInfo.h"
|
||||
#include "TexturePage.h"
|
||||
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define MAX_OUTPUT_FILE_LEN 128
|
||||
#define DEFAULT_TARGET_SIZE 512
|
||||
|
||||
// ImagePacker ----------------------------------------------------------------
|
||||
// Class interface for running the image packer */
|
||||
//-----------------------------------------------------------------------------
|
||||
class ImagePacker
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
GAP_METHOD_EXTEND_RGB = 0x00000001, ///< extend RGB (no alpha) of image on all sides
|
||||
GAP_METHOD_GUTTER = 0x00000002, ///< put transparent gutter on right and bottom side of image
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
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
|
||||
|
||||
ICoord2D *getTargetSize( 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
|
||||
ImageInfo *getImage( Int index ); ///< get image
|
||||
TexturePage *getFirstTexturePage( 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:
|
||||
|
||||
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
|
||||
|
||||
TexturePage *createNewTexturePage( void ); ///< create a new texture page
|
||||
|
||||
void sortImageList( void ); ///< sort the image list
|
||||
|
||||
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
|
||||
|
||||
ImageDirectory *m_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
|
||||
TexturePage *m_pageTail; ///< end of the texture page list
|
||||
TexturePage *m_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
|
||||
|
||||
Targa *m_targa; ///< targa for loading file headers
|
||||
Bool m_compressTextures; ///< compress the final textures
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline void ImagePacker::setTargetSize( Int width, Int height ) { m_targetSize.x = width; m_targetSize.y = height; }
|
||||
inline ICoord2D *ImagePacker::getTargetSize( void ) { return &m_targetSize; }
|
||||
inline Int ImagePacker::getTargetWidth( void ) { return m_targetSize.x; }
|
||||
inline Int ImagePacker::getTargetHeight( void ) { return m_targetSize.y; }
|
||||
inline void ImagePacker::setWindowHandle( HWND hWnd ) { m_hWnd = hWnd; }
|
||||
inline HWND ImagePacker::getWindowHandle( void ) { return m_hWnd; }
|
||||
inline UnsignedInt ImagePacker::getImageCount( void ) { return m_imageCount; }
|
||||
inline ImageInfo *ImagePacker::getImage( Int index ) { return m_imageList[ index ]; }
|
||||
inline void ImagePacker::setTargetPreviewPage( Int page ) { m_targetPreviewPage = page; }
|
||||
inline Int ImagePacker::getTargetPreviewPage( void ) { return m_targetPreviewPage; }
|
||||
inline UnsignedInt ImagePacker::getPageCount( void ) { return m_pageCount; }
|
||||
inline void ImagePacker::setPreviewWindow( HWND window ) { m_hWndPreview = window; }
|
||||
inline HWND ImagePacker::getPreviewWindow( void ) { return m_hWndPreview; }
|
||||
inline void ImagePacker::setGutter( UnsignedInt size ) { m_gutterSize = size; }
|
||||
inline UnsignedInt ImagePacker::getGutter( void ) { return m_gutterSize; }
|
||||
inline void ImagePacker::setOutputAlpha( Bool outputAlpha ) { m_outputAlpha = outputAlpha; }
|
||||
inline Bool ImagePacker::getOutputAlpha( void ) { return m_outputAlpha; }
|
||||
inline TexturePage *ImagePacker::getFirstTexturePage( void ) { return m_pageList; }
|
||||
inline void ImagePacker::setUseTexturePreview( Bool use ) { m_showTextureInPreview = use; }
|
||||
inline Bool ImagePacker::getUseTexturePreview( void ) { return m_showTextureInPreview; }
|
||||
inline void ImagePacker::setINICreate( Bool create ) { m_createINI = create; };
|
||||
inline Bool ImagePacker::createINIFile( void ) { return m_createINI; }
|
||||
inline char *ImagePacker::getOutputFile( void ) { return m_outputFile; }
|
||||
inline char *ImagePacker::getOutputDirectory( void ) { return m_outputDirectory; }
|
||||
inline void ImagePacker::setCompressTextures( Bool compress ) { m_compressTextures = compress; }
|
||||
inline Bool ImagePacker::getCompressTextures( void ) { return m_compressTextures; }
|
||||
inline void ImagePacker::setGapMethod( UnsignedInt methodBit ) { BitSet( m_gapMethod, methodBit ); }
|
||||
inline void ImagePacker::clearGapMethod( UnsignedInt methodBit ) { BitClear( m_gapMethod, methodBit ); }
|
||||
inline UnsignedInt ImagePacker::getGapMethod( void ) { return m_gapMethod; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern ImagePacker *TheImagePacker;
|
||||
|
||||
#endif // __IMAGEPACKER_H_
|
||||
|
172
GeneralsMD/Code/Tools/ImagePacker/Include/TexturePage.h
Normal file
172
GeneralsMD/Code/Tools/ImagePacker/Include/TexturePage.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: TexturePage.h ////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: TexturePage.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: This class represents a texture that contains packed
|
||||
// images.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __TEXTUREPAGE_H_
|
||||
#define __TEXTUREPAGE_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
#include <stdlib.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "WWLib/Targa.h"
|
||||
#include "Lib/BaseType.h"
|
||||
#include "ImageInfo.h"
|
||||
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TexturePage ----------------------------------------------------------------
|
||||
/** A texture page continaing multiple source images */
|
||||
//-----------------------------------------------------------------------------
|
||||
class TexturePage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
FREE = 0, ///< open pixel in the cavas
|
||||
USED = 1, ///< used pixel in the canvas
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
READY = 0x00000001, ///< texture page here and OK
|
||||
PAGE_ERROR = 0x00000002, ///< error on page somewhere
|
||||
CANT_ALLOCATE_PACKED_IMAGE = 0x00000004, ///< couldn't generate final image
|
||||
CANT_ADD_IMAGE_DATA = 0x00000008, ///< couldn't add image data to page
|
||||
NO_TEXTURE_DATA = 0x00000010, ///< there was no image data to write
|
||||
ERROR_DURING_SAVE = 0x00000020, ///< couldn't save final file
|
||||
};
|
||||
|
||||
TexturePage( Int width, Int height );
|
||||
~TexturePage( void );
|
||||
|
||||
Bool addImage( ImageInfo *image ); ///< try to add image to this page
|
||||
|
||||
void setID( Int id ); ///< set page id
|
||||
Int getID( void ); ///< get page id
|
||||
|
||||
Bool generateTexture( void ); ///< generate the final packed texture
|
||||
Bool writeFile( char *baseFilename ); ///< write generated texture to file
|
||||
|
||||
ImageInfo *getFirstImage( void ); ///< get the first image in the list
|
||||
|
||||
Int getWidth( void ); ///< get width of texture page
|
||||
Int getHeight( void ); ///< get height of texture page
|
||||
|
||||
// get rgb from final generated texture (putting this in for quick preview)
|
||||
void getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a = NULL );
|
||||
|
||||
TexturePage *m_next;
|
||||
TexturePage *m_prev;
|
||||
|
||||
UnsignedInt m_status; ///< status bits
|
||||
|
||||
protected:
|
||||
|
||||
Bool spotUsed( Int x, Int y ); ///< is this spot used
|
||||
Bool lineUsed( Int sx, Int sy, Int ex, Int ey ); ///< is any spot on the line used
|
||||
|
||||
/// build a region to try to fit given the position, size, and border options
|
||||
UnsignedInt buildFitRegion( IRegion2D *region,
|
||||
Int startX, Int startY,
|
||||
Int imageWidth, Int imageHeight,
|
||||
Int *xGutter, Int *yGutter,
|
||||
Bool allSidesBorder );
|
||||
|
||||
void markRegionUsed( IRegion2D *region ); ///< mark this region as used
|
||||
|
||||
/// add the actual image data of 'image' to the destination buffer
|
||||
Bool addImageData( Byte *destBuffer,
|
||||
Int destWidth,
|
||||
Int destHeight,
|
||||
Int destBPP,
|
||||
ImageInfo *image );
|
||||
|
||||
/// extend edges of image outward into border if present
|
||||
void extendImageEdges( Byte *destBuffer,
|
||||
Int destWidth,
|
||||
Int destHeight,
|
||||
Int destBPP,
|
||||
ImageInfo *image,
|
||||
Bool extendAlpha );
|
||||
|
||||
/// if the pixel at abolve/below row is open, extend pixel at src to its location
|
||||
void extendToRowIfOpen( char *src,
|
||||
Int buffWidth,
|
||||
Int buffBPP,
|
||||
Bool extendAlpha,
|
||||
Int imageHeight,
|
||||
UnsignedInt fitBits,
|
||||
Int srcX, Int srcY );
|
||||
|
||||
|
||||
Int m_id; ///< texture page ID
|
||||
ICoord2D m_size; ///< dimensions of texture page
|
||||
UnsignedByte *m_canvas; ///< as big as the texture page, a used spot is non zero
|
||||
|
||||
ImageInfo *m_imageList; ///< list of images packed on this page
|
||||
|
||||
Byte *m_packedImage; ///< final generated image data
|
||||
Targa *m_targa; ///< final packed image all in a nice little targa file
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline void TexturePage::setID( Int id ) { m_id = id; }
|
||||
inline Int TexturePage::getID( void ) { return m_id; }
|
||||
inline ImageInfo *TexturePage::getFirstImage( void ) { return m_imageList; }
|
||||
inline Int TexturePage::getWidth( void ) { return m_size.x; }
|
||||
inline Int TexturePage::getHeight( void ) { return m_size.y; }
|
||||
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // __TEXTUREPAGE_H_
|
||||
|
62
GeneralsMD/Code/Tools/ImagePacker/Include/WinMain.h
Normal file
62
GeneralsMD/Code/Tools/ImagePacker/Include/WinMain.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: WinMain.h ////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: WinMain.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: Header for main app
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WINMAIN_H_
|
||||
#define __WINMAIN_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
#include <windows.h>
|
||||
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern HINSTANCE ApplicationHInstance;
|
||||
|
||||
#endif // __WINMAIN_H_
|
||||
|
74
GeneralsMD/Code/Tools/ImagePacker/Include/WindowProc.h
Normal file
74
GeneralsMD/Code/Tools/ImagePacker/Include/WindowProc.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: WindowProc.h /////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: ImagePacker
|
||||
//
|
||||
// File name: WindowProc.h
|
||||
//
|
||||
// Created: Colin Day, August 2001
|
||||
//
|
||||
// Desc: Dialog procedure header for image packer utility
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WINDOWPROC_H_
|
||||
#define __WINDOWPROC_H_
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
|
||||
// USER INCLUDES //////////////////////////////////////////////////////////////
|
||||
|
||||
// FORWARD REFERENCES /////////////////////////////////////////////////////////
|
||||
|
||||
// TYPE DEFINES ///////////////////////////////////////////////////////////////
|
||||
|
||||
// INLINING ///////////////////////////////////////////////////////////////////
|
||||
|
||||
// EXTERNALS //////////////////////////////////////////////////////////////////
|
||||
extern BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
extern HWND MakePreviewDisplay( void );
|
||||
extern void UpdatePreviewWindow( void );
|
||||
extern LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
extern BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
extern BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
extern BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
#endif // __WINDOWPROC_H_
|
||||
|
Reference in a new issue