Batch #10229 by ragnarok-clanker: forced by an admin (4 lower score(s), 45 changed function(s)); checked with 314 compiled unit(s), including every includer of Source/Resource/Bitmap/BitmapImage.h, Source/Resource/Bitmap/BitmapResource.h, Source/Resource/Bitmap/IJL15Runtime.h, Source/Resource/EmblemResource.h, Source/Resource/GifResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Models/ModelResource.h, Source/Resource/Sprites/ActionResource.h, Source/Resource/Sprites/SpriteResource.h, Source/UI/Buttons/UIBmpRadioBtn.h.
68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
#include "Client/Application/ErrorDialog.h"
|
|
#include "File/File.h"
|
|
#include "Render/DeviceContext/DCSurface.h"
|
|
#include "Resource/Bitmap/BitmapResource.h"
|
|
|
|
#include <cstring>
|
|
#include <windows.h>
|
|
|
|
// INLINED
|
|
CBitmapRes::~CBitmapRes() = default;
|
|
|
|
// OFFSET: 0x00749580
|
|
// FUNCTION: fn_07847
|
|
CBitmapRes* CBitmapRes::Create() {
|
|
return new CBitmapRes;
|
|
}
|
|
|
|
// OFFSET: 0x00749630
|
|
// FUNCTION: fn_07848
|
|
bool CBitmapRes::Load(const char* name) {
|
|
CFile file;
|
|
bool result = false;
|
|
if (name && file.Open(name, 0, true, false)) {
|
|
if (this->Decode(name, file.GetData(), file.GetSize(), false)) {
|
|
file.Close();
|
|
result = true;
|
|
} else {
|
|
file.Close();
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
if (lstrcmpiA(extension, ".png") == 0) {
|
|
return this->image.DecodePng(data, bytes, name);
|
|
}
|
|
|
|
ShowErrorDialog(GetRenderSystemHolder()->system, "Unsupport fileformat!", 0);
|
|
return false;
|
|
}
|