Initial implementation of MxBitmap (#34)

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
This commit is contained in:
Joshua Peisach 2023-06-30 19:24:00 -04:00 committed by GitHub
parent e929d76f3c
commit 428b5ae8db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 9 deletions

View file

@ -3,25 +3,72 @@
// OFFSET: LEGO1 0x100bc980 // OFFSET: LEGO1 0x100bc980
MxBitmap::MxBitmap() MxBitmap::MxBitmap()
{ {
// TODO this->m_info = NULL;
this->m_bmiHeader = NULL;
this->m_paletteData = NULL;
this->m_data = NULL;
this->m_unk18 = FALSE;
this->m_palette = NULL;
} }
// OFFSET: LEGO1 0x100bca10 // OFFSET: LEGO1 0x100bca10
MxBitmap::~MxBitmap() MxBitmap::~MxBitmap()
{ {
// TODO if (this->m_info != NULL) {
delete m_info;
}
if (this->m_data != NULL) {
delete m_data;
}
if (this->m_palette != NULL) {
delete m_palette;
}
} }
// OFFSET: LEGO1 0x100bd1c0 // OFFSET: LEGO1 0x100bd1c0
MxPalette *MxBitmap::CreatePalette() MxPalette *MxBitmap::CreatePalette()
{ {
// TODO // FIXME: This function needs MxPalette to be completed. Also INFERRING usage of MxBool
return NULL; MxPalette *pal = NULL;
MxPalette *ppal;
MxBool success = FALSE;
if(this->m_unk18 == FALSE) {
// ppal = MxPalette::FromBitmapPalette(this->m_paletteData);
} else {
if(this->m_unk18 != TRUE) {
if(!success && pal != NULL) {
delete pal;
pal = NULL;
}
}
//.pal = MxPalette::Clone(this->m_palette);
}
if(pal != NULL) {
success = TRUE;
}
return pal;
} }
// OFFSET: LEGO1 0x100bcd10 // OFFSET: LEGO1 0x100bcd10
long MxBitmap::Read(const char *) long MxBitmap::Read(const char *filename)
{ {
// TODO HANDLE handle;
return 0; int unk1;
MxResult ret = FAILURE;
handle = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ,(LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,(HANDLE)NULL);
if(handle != (HANDLE)INVALID_HANDLE_VALUE) { // INVALID_HANDLE_VALUE = -1, or 0xffffffff
// FIXME: line 16. iVar gets changed in this line
if(unk1 == 0) {
ret = SUCCESS;
}
}
if(handle != (HANDLE)NULL) {
CloseHandle(handle);
}
return ret;
} }

View file

@ -1,15 +1,26 @@
#ifndef MXBITMAP_H #ifndef MXBITMAP_H
#define MXBITMAP_H #define MXBITMAP_H
#include "mxpalette.h" #include <stdlib.h>
class MxBitmap #include "mxcore.h"
#include "mxpalette.h"
#include "mxtypes.h"
class MxBitmap : public MxCore
{ {
public: public:
__declspec(dllexport) MxBitmap(); __declspec(dllexport) MxBitmap();
__declspec(dllexport) virtual ~MxBitmap(); __declspec(dllexport) virtual ~MxBitmap();
__declspec(dllexport) virtual MxPalette *CreatePalette(); __declspec(dllexport) virtual MxPalette *CreatePalette();
__declspec(dllexport) virtual long Read(const char *); __declspec(dllexport) virtual long Read(const char *);
private:
BITMAPINFO *m_info;
BITMAPINFOHEADER *m_bmiHeader;
RGBQUAD *m_paletteData;
LPVOID *m_data;
MxBool m_unk18;
MxPalette *m_palette;
}; };
#endif // MXBITMAP_H #endif // MXBITMAP_H