mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-21 07:11:16 +00:00
Cleanup MxBitmap::LoadFile
This commit is contained in:
parent
c5f7a4df28
commit
0223d8fb50
@ -3,7 +3,7 @@
|
|||||||
// The way that the BITMAPFILEHEADER structure ensures the file type is by ensuring it is "BM", which is literally just 0x424d.
|
// The way that the BITMAPFILEHEADER structure ensures the file type is by ensuring it is "BM", which is literally just 0x424d.
|
||||||
// Sources: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapfileheader, DirectX Complete (1998)
|
// Sources: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapfileheader, DirectX Complete (1998)
|
||||||
// GLOBAL: LEGO1 0x10102184
|
// GLOBAL: LEGO1 0x10102184
|
||||||
WORD g_bitmapSignature = 0x424d;
|
DWORD g_bitmapSignature = 0x424d;
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100bc980
|
// OFFSET: LEGO1 0x100bc980
|
||||||
MxBitmap::MxBitmap()
|
MxBitmap::MxBitmap()
|
||||||
@ -72,26 +72,24 @@ int MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int)
|
|||||||
// OFFSET: LEGO1 0x100bcd60
|
// OFFSET: LEGO1 0x100bcd60
|
||||||
MxResult MxBitmap::LoadFile(HANDLE p_handle)
|
MxResult MxBitmap::LoadFile(HANDLE p_handle)
|
||||||
{
|
{
|
||||||
void* lpBuffer;
|
LPVOID* lpBuffer;
|
||||||
BITMAPINFO *infoHdr;
|
|
||||||
MxS32 height;
|
MxS32 height;
|
||||||
MxBool operation_ret;
|
MxBool ret;
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
DWORD bytesRead;
|
DWORD bytesRead;
|
||||||
BITMAPFILEHEADER hdr;
|
BITMAPFILEHEADER hdr;
|
||||||
|
|
||||||
operation_ret = ReadFile(p_handle, &hdr, 14, &bytesRead, NULL);
|
ret = ReadFile(p_handle, &hdr, 14, &bytesRead, NULL);
|
||||||
if ((operation_ret != 0) && (hdr.bfType == g_bitmapSignature)) {
|
if (ret && (hdr.bfType == g_bitmapSignature)) {
|
||||||
infoHdr = (BITMAPINFO*) malloc(1064);
|
this->m_info = (BITMAPINFO*) malloc(1064);
|
||||||
this->m_info = infoHdr;
|
if(this->m_info != NULL) {
|
||||||
if(infoHdr != NULL) {
|
ret = ReadFile(p_handle, this->m_info, 1064, &bytesRead, NULL);
|
||||||
operation_ret = ReadFile(p_handle, infoHdr, 1064, &bytesRead, NULL);
|
if (ret && ((this->m_info->bmiHeader).biBitCount == 8)) {
|
||||||
if ((operation_ret != 0) && ((this->m_info->bmiHeader).biBitCount == 8)) {
|
lpBuffer = (LPVOID*) malloc(hdr.bfSize - 1078);
|
||||||
lpBuffer = (void*) malloc(hdr.bfSize - 1078);
|
this->m_data = lpBuffer;
|
||||||
this->m_data = (LPVOID*) lpBuffer;
|
|
||||||
if (this->m_data != NULL) {
|
if (this->m_data != NULL) {
|
||||||
operation_ret = ReadFile(p_handle, lpBuffer, hdr.bfSize - 1078, &bytesRead, NULL);
|
ret = ReadFile(p_handle, lpBuffer, hdr.bfSize - 1078, &bytesRead, NULL);
|
||||||
if(operation_ret != 0) {
|
if(ret != 0) {
|
||||||
this->m_bmiHeader = &this->m_info->bmiHeader;
|
this->m_bmiHeader = &this->m_info->bmiHeader;
|
||||||
this->m_paletteData = this->m_info->bmiColors;
|
this->m_paletteData = this->m_info->bmiColors;
|
||||||
if((this->m_info->bmiHeader).biSizeImage == 0) {
|
if((this->m_info->bmiHeader).biSizeImage == 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user