rodecomp/Source/Resource/Bitmap/BitmapResource.cpp
ragnarok-clanker e168b4e4a6 Restore translation-unit ownership and publish verified source corrections
Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas.

449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
2026-10-25 15:42:21 +00:00

71 lines
1.7 KiB
C++

#include "Client/Application/ErrorDialog.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Resource/Bitmap/IJL15Runtime.h"
#include <cstring>
#include <windows.h>
// OFFSET: 0x00749580
// FUNCTION: fn_07861
CBitmapRes::CBitmapRes(BitmapResourceContext& context) : m_context(&context) {
}
// INLINED
CBitmapRes::~CBitmapRes() = default;
// OFFSET: 0x00749580
// FUNCTION: fn_07847
CBitmapRes* CBitmapRes::Create() {
return new CBitmapRes(*this->m_context);
}
// OFFSET: 0x00749630
// FUNCTION: fn_07848
bool CBitmapRes::Load(const char* name) {
bool result = false;
if (name && this->m_context->file.Open(name)) {
if (this->Decode(name, this->m_context->file.Data(), this->m_context->file.Size(), false)) {
this->m_context->file.Close();
result = true;
} else {
this->m_context->file.Close();
}
}
this->m_context->file.Close();
return result;
}
// OFFSET: 0x00749850
// FUNCTION: fn_07850
void CBitmapRes::Unload() {
this->image.Clear();
}
// OFFSET: 0x00749780
// FUNCTION: fn_07849
bool CBitmapRes::Decode(const char* name, const void* data, int bytes, bool iconOnly) {
const char* extension = std::strrchr(name, '.');
if (!extension) {
return false;
}
if (lstrcmpiA(extension, ".bmp") == 0) {
return this->image.DecodeBitmap(data, bytes, iconOnly);
}
if (lstrcmpiA(extension, ".tga") == 0) {
return this->image.DecodeTga(data, bytes);
}
if (lstrcmpiA(extension, ".jpg") == 0) {
return this->image.DecodeJpeg(data, bytes, this->m_context->jpeg);
}
if (lstrcmpiA(extension, ".png") == 0) {
return this->image.DecodePng(data, bytes, name);
}
ShowErrorDialog(this->m_context->renderSystem, "Unsupport fileformat!", 0);
return false;
}