fill info for CKBitmapData

This commit is contained in:
yyc12345 2023-09-10 13:23:04 +08:00
parent 138e47cbdc
commit e907c18f35
6 changed files with 189 additions and 3 deletions

View File

@ -119,6 +119,14 @@ public class MainRunner {
GeneralWriter.writeAccVal(fs, single, CommonHelper.CKParts.CK2);
fs.close();
single = organiseDefines("src/CK_BITMAPDATA_FLAGS.txt", "CK_BITMAPDATA_FLAGS");
fs = CommonHelper.openOutputFile("dest/CK_BITMAPDATA_FLAGS.hpp");
GeneralWriter.writeEnum(fs, single);
fs.close();
fs = CommonHelper.openOutputFile("dest/CK_BITMAPDATA_FLAGS.AccVal.hpp");
GeneralWriter.writeAccVal(fs, single, CommonHelper.CKParts.CK2);
fs.close();
// print message.
System.out.println("DONE!");
}

View File

@ -0,0 +1,14 @@
#define CKBITMAPDATA_INVALID 1
#define CKBITMAPDATA_TRANSPARENT 2
#define CKBITMAPDATA_FORCERESTORE 4
#define CKBITMAPDATA_CLAMPUPTODATE 8
#define CKBITMAPDATA_CUBEMAP 16
#define CKBITMAPDATA_FREEVIDEOMEMORY 32
#define CKBITMAPDATA_DYNAMIC 64

View File

@ -2,7 +2,32 @@
namespace LibCmo::CK2 {
CKBitmapData::CKBitmapData() {}
#pragma region Assist RW Functions
bool CKBitmapData::ReadSpecificFormatBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc) {
return false;
}
bool CKBitmapData::ReadRawBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc) {
return false;
}
bool CKBitmapData::ReadOldRawBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc) {
return false;
}
void CKBitmapData::WriteSpecificFormatBitmap(CKStateChunk* chk, const VxMath::VxImageDescEx* desc) {
}
void CKBitmapData::WriteRawBitmap(CKStateChunk* chk, const VxMath::VxImageDescEx* desc) {
}
#pragma endregion
CKBitmapData::CKBitmapData(CKContext* ctx) {}
CKBitmapData::~CKBitmapData() {}

View File

@ -4,13 +4,142 @@
namespace LibCmo::CK2 {
struct CKBitmapDataReadIdentifiers {
CKDWORD m_SpecificFormat; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXREADER(0x100000) in default. */
CKDWORD m_RawData; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXCOMPRESSED(0x20000) in default. */
CKDWORD m_OldRawData; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXBITMAPS(0x4000) in default. */
CKDWORD m_FileNames; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXFILENAMES(0x10000) in default. */
CKDWORD m_MovieFileName; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXAVIFILENAME(0x1000) in default. */
};
struct CKBitmapDataWriteIdentifiers {
CKDWORD m_SpecificFormat; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXREADER(0x100000) in default. */
CKDWORD m_RawData; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXCOMPRESSED(0x20000) in default. */
CKDWORD m_FileNames; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXFILENAMES(0x10000) in default. */
CKDWORD m_MovieFileName; /**< CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXAVIFILENAME(0x1000) in default. */
};
class CKBitmapSlot {
public:
CKBitmapSlot() :
m_ImageData(nullptr), m_FileName() {}
~CKBitmapSlot() {
FreeImage();
}
void CreateImage(CKDWORD Width, CKDWORD Height) {
FreeImage();
m_ImageData = new VxMath::VxImageDescEx(Width, Height);
}
void FreeImage() {
if (m_ImageData != nullptr) {
delete m_ImageData;
m_ImageData = nullptr;
}
}
VxMath::VxImageDescEx* m_ImageData;
XContainer::XString m_FileName;
};
class CKBitmapData {
public:
CKBitmapData();
CKBitmapData(CKContext* ctx);
~CKBitmapData();
LIBCMO_DISABLE_COPY_MOVE(CKBitmapData);
static bool ReadSpecificFormatBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc);
static bool ReadRawBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc);
static bool ReadOldRawBitmap(CKStateChunk* chk, VxMath::VxImageDescEx* desc);
static void WriteSpecificFormatBitmap(CKStateChunk* chk, const VxMath::VxImageDescEx* desc);
static void WriteRawBitmap(CKStateChunk* chk, const VxMath::VxImageDescEx* desc);
bool ReadFromChunk(CKStateChunk* chunk, CKFileVisitor* file, const CKBitmapDataReadIdentifiers& identifiers);
bool DumpToChunk(CKStateChunk* chunk, CKFileVisitor* file, const CKBitmapDataWriteIdentifiers& identifiers);
void SetSlotCount(CKDWORD count);
CKDWORD GetSlotCount();
void SetCurrentSlot(CKDWORD slot);
CKDWORD GetCurrentSlot();
void CreateImage(CKDWORD Width, CKDWORD Height, CKDWORD Slot);
bool LoadImage(CKSTRING filename, CKDWORD slot);
bool SaveImage(CKSTRING filename, CKDWORD slot);
VxMath::VxImageDescEx* GetImageDesc(CKDWORD slot);
void ReleaseImage(CKDWORD slot);
void SetSlotFileName(CKDWORD slot, CKSTRING filename);
CKSTRING GetSlotFileName(CKDWORD slot);
const CKBitmapProperties& GetSaveProperties();
void SetSaveProperties(const CKBitmapProperties& props);
CK_TEXTURE_SAVEOPTIONS GetSaveOptions();
void SetSaveOptions(CK_TEXTURE_SAVEOPTIONS opts);
VxMath::VX_PIXELFORMAT GetDesiredVideoFormat();
void SetDesiredVideoFormat(VxMath::VX_PIXELFORMAT fmt);
/**
Summary: Enables or disables the color key transparency.
Arguments:
Transparency: TRUE activates transparency, FALSE disables it.
Remarks:
+ 0x00000000 (black) is the default transparent color.
+ Setting on the transparency and a transparent color automatically
updates the alpha channel so that pixel with the transparent color have
a 0 alpha value.
See also: IsTransparent,SetTranparentColor
*/
void SetTransparent(bool Transparency);
/**
Summary: Returns whether color keyed transparency is enabled.
Return Value:
TRUE if successful.
Arguments:
Transparency: TRUE activates transparency, FALSE disables it.
Return Value:
TRUE if color keying is enabled.
See also: IsTransparent
*/
bool IsTransparent();
/**
Summary: Returns the transparent color.
Return Value:
Color: A 32 bit ARGB transparent color.
Remarks:
+ 0x00000000 (black) is the default transparent color.
See also: SetTranparentColor,SetTransparent
*/
CKDWORD GetTransparentColor();
/**
Summary: Sets the transparent color.
Arguments:
Color: A 32 bit ARGB transparent color.
Remarks:
+ 0x00000000 (black) is the default transparent color.
+ Setting on the transparency and a transparent color automatically
updates the alpha channel so that pixel with the transparent color have
a 0 alpha value.
See also: GetTranparentColor,SetTransparent
*/
void SetTransparentColor(CKDWORD col);
protected:
CKContext* m_Context;
XContainer::XArray<CKBitmapSlot> m_Slots;
CKDWORD m_CurrentSlot;
CKINT m_PickThreshold;
CKDWORD m_BitmapFlags;
CKDWORD m_TransColor;
CKBitmapProperties m_SaveProperties;
CK_TEXTURE_SAVEOPTIONS m_SaveOptions;
VxMath::VX_PIXELFORMAT m_DesiredVideoFormat;
};
}

View File

@ -346,4 +346,14 @@ namespace LibCmo::CK2 {
CKSOUND_USEGLOBAL = 2, /**< Use Global settings. This flag is only valid for the CKSound::SetSaveOptions method. */
};
enum class CK_BITMAPDATA_FLAGS : uint32_t {
CKBITMAPDATA_INVALID = 1,
CKBITMAPDATA_TRANSPARENT = 2,
CKBITMAPDATA_FORCERESTORE = 4,
CKBITMAPDATA_CLAMPUPTODATE = 8,
CKBITMAPDATA_CUBEMAP = 16,
CKBITMAPDATA_FREEVIDEOMEMORY = 32,
CKBITMAPDATA_DYNAMIC = 64,
};
}

View File

@ -78,7 +78,7 @@ namespace LibCmo::VxMath {
*/
class VxImageDescEx {
public:
VxImageDescEx(CK2::CKDWORD height, CK2::CKDWORD width) :
VxImageDescEx(CK2::CKDWORD width, CK2::CKDWORD height) :
m_Width(width), m_Height(height),
//m_RedMask(0), m_GreenMask(0), m_BlueMask(0), m_AlphaMask(0),
m_Image(nullptr){