diff --git a/Source/Resource/Bitmap/BitmapImage.cpp b/Source/Resource/Bitmap/BitmapImage.cpp index acce50fe6..147b6957e 100644 --- a/Source/Resource/Bitmap/BitmapImage.cpp +++ b/Source/Resource/Bitmap/BitmapImage.cpp @@ -1,4 +1,4 @@ -#include "Resource/Bitmap/BitmapImage.h" +#include "Resource/Bitmap/BitmapResource.h" #include #include @@ -71,17 +71,17 @@ namespace { // OFFSET: 0x0074A680 // FUNCTION: fn_07866 -bool BitmapImage::CreateAuxiliary(int mode) { - if (!this->pixels || this->auxiliary) { +bool CBitmapRes::CreateAuxiliary(int mode) { + if (!this->image.pixels || this->image.auxiliary) { return false; } - this->auxiliary = new std::uint32_t[this->width * this->height]; - std::memset(this->auxiliary, 255, 4u * this->width * this->height); - for (int y = 0; y < this->height; ++y) { - for (int x = 0; x < this->width; ++x) { - const int index = this->width * y + x; - const std::uint32_t value = this->pixels[index]; + this->image.auxiliary = new std::uint32_t[this->image.width * this->image.height]; + std::memset(this->image.auxiliary, 255, 4u * this->image.width * this->image.height); + for (int y = 0; y < this->image.height; ++y) { + for (int x = 0; x < this->image.width; ++x) { + const int index = this->image.width * y + x; + const std::uint32_t value = this->image.pixels[index]; unsigned red = (value >> 16) & 255; unsigned green = (value >> 8) & 255; const unsigned alpha = value >> 24; @@ -103,7 +103,7 @@ bool BitmapImage::CreateAuxiliary(int mode) { blue = 200; } } - static_cast(this->auxiliary)[index] = Color(alpha, red, green, blue); + static_cast(this->image.auxiliary)[index] = Color(alpha, red, green, blue); } } return true; @@ -111,26 +111,26 @@ bool BitmapImage::CreateAuxiliary(int mode) { // OFFSET: 0x0074A7F0 // FUNCTION: fn_07867 -std::uint32_t BitmapImage::Pixel(int x, int y) const { - if (x < 0 || x >= this->width || y < 0 || y >= this->height) { +std::uint32_t CBitmapRes::Pixel(int x, int y) const { + if (x < 0 || x >= this->image.width || y < 0 || y >= this->image.height) { return 0x00FF0000; } - return this->pixels[x + y * this->width]; + return this->image.pixels[x + y * this->image.width]; } // OFFSET: 0x0074C540 // FUNCTION: fn_07874 -void BitmapImage::ClearAuxiliary() { - if (this->auxiliary) { - delete[] static_cast(this->auxiliary); - this->auxiliary = nullptr; +void CBitmapRes::ClearAuxiliary() { + if (this->image.auxiliary) { + delete[] static_cast(this->image.auxiliary); + this->image.auxiliary = nullptr; } } // OFFSET: 0x0074AB00 // FUNCTION: fn_07869 -bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { - this->Clear(); +bool CBitmapRes::DecodeBitmap(const void* input, int, bool iconOnly) { + this->Unload(); const auto* data = static_cast(input); BITMAPFILEHEADER fileHeader; @@ -167,10 +167,10 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { return false; } - this->height = height; - this->width = width; + this->image.height = height; + this->image.width = width; rgb = new unsigned char[height * width * 3]; - this->pixels = new std::uint32_t[this->width * this->height]; + this->image.pixels = new std::uint32_t[this->image.width * this->image.height]; if (bits == 8) { const std::uint32_t count = Read32(source); @@ -184,30 +184,30 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { source = ReadPalette(palette, first, second, source, 256); } - DecodeIndexedRows(*this, rgb, source, palette, row); + DecodeIndexedRows(this->image, rgb, source, palette, row); } else if (bits == 24) { - auto* first = new unsigned char[this->width * this->height * 3]; - auto* second = new unsigned char[this->width * this->height * 2]; + auto* first = new unsigned char[this->image.width * this->image.height * 3]; + auto* second = new unsigned char[this->image.width * this->image.height * 2]; unsigned char* target = first; - for (int y = this->height - 1; y >= 0; --y) { - std::memcpy(target, source, this->width * 2); - target += this->width * 2; - source += this->width * 2; + for (int y = this->image.height - 1; y >= 0; --y) { + std::memcpy(target, source, this->image.width * 2); + target += this->image.width * 2; + source += this->image.width * 2; } target = second; - for (int y = this->height - 1; y >= 0; --y) { - std::memcpy(target, source, this->width); - target += this->width; - source += this->width; + for (int y = this->image.height - 1; y >= 0; --y) { + std::memcpy(target, source, this->image.width); + target += this->image.width; + source += this->image.width; } unsigned char* pixel = rgb; int index = 0; - for (int y = 0; y < this->height; ++y) { - for (int x = 0; x < this->width; ++x) { - pixel[0] = *(second + this->width * y + x); + for (int y = 0; y < this->image.height; ++y) { + for (int x = 0; x < this->image.width; ++x) { + pixel[0] = *(second + this->image.width * y + x); pixel[1] = first[index]; pixel[2] = first[index + 1]; index += 2; @@ -237,11 +237,11 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { return false; } - this->height = infoHeader.biHeight; + this->image.height = infoHeader.biHeight; const std::uint32_t stride = (infoHeader.biWidth + 3) & ~3u; - this->width = infoHeader.biWidth; + this->image.width = infoHeader.biWidth; rgb = new unsigned char[infoHeader.biHeight * infoHeader.biWidth * 3]; - this->pixels = new std::uint32_t[this->width * this->height]; + this->image.pixels = new std::uint32_t[this->image.width * this->image.height]; if (infoHeader.biBitCount == 8) { std::uint32_t paletteSize; @@ -258,7 +258,7 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { return false; } - DecodeIndexedRows(*this, rgb, data + fileHeader.bfOffBits, palette, row); + DecodeIndexedRows(this->image, rgb, data + fileHeader.bfOffBits, palette, row); } else if (infoHeader.biBitCount == 24) { if (fileHeader.bfOffBits > sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)) { return false; @@ -266,27 +266,27 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { const unsigned char* source = data + fileHeader.bfOffBits; - for (int y = this->height - 1; y >= 0; --y) { - std::memcpy(rgb + this->width * y * 3, source, this->width * 3); - source += this->width * 3; + for (int y = this->image.height - 1; y >= 0; --y) { + std::memcpy(rgb + this->image.width * y * 3, source, this->image.width * 3); + source += this->image.width * 3; - if (stride - this->width != 0) { - source += this->width - stride + 4; + if (stride - this->image.width != 0) { + source += this->image.width - stride + 4; } } } } - for (int y = 0; y < this->height; ++y) { - const unsigned char* source = rgb + this->width * y * 3; + for (int y = 0; y < this->image.height; ++y) { + const unsigned char* source = rgb + this->image.width * y * 3; if (source) { - std::uint32_t* target = this->pixels + this->width * y; + std::uint32_t* target = this->image.pixels + this->image.width * y; if (target) { *target++ = Color(255, source[2], source[1], source[0]); - for (int x = 1; x < this->width; ++x) { + for (int x = 1; x < this->image.width; ++x) { source += 3; *target++ = Color(255, source[2], source[1], source[0]); } @@ -298,7 +298,7 @@ bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) { delete[] rgb; } - this->alpha = 0; + this->image.alpha = 0; return true; } @@ -328,7 +328,7 @@ struct TgaPixel { // OFFSET: 0x0074C300 // FUNCTION: fn_07873 -bool BitmapImage::DecodeTga(const void* input, int) { +bool CBitmapRes::DecodeTga(const void* input, int) { const auto* source = static_cast(input); const TgaHeader header = *static_cast(input); source += sizeof(header); @@ -340,10 +340,10 @@ bool BitmapImage::DecodeTga(const void* input, int) { source += header.idLength; } - this->width = header.width; - this->height = header.height; - this->pixels = new std::uint32_t[this->width * this->height]; - std::uint32_t* row = this->pixels + (this->height - 1) * this->width; + this->image.width = header.width; + this->image.height = header.height; + this->image.pixels = new std::uint32_t[this->image.width * this->image.height]; + std::uint32_t* row = this->image.pixels + (this->image.height - 1) * this->image.width; TgaPixel pixel = {}; pixel.alpha = 255; // INLINED @@ -358,10 +358,10 @@ bool BitmapImage::DecodeTga(const void* input, int) { return Color(pixel.alpha, pixel.red, pixel.green, pixel.blue); }; - for (int y = 0; y < this->height; ++y) { + for (int y = 0; y < this->image.height; ++y) { int x = 0; - while (x < this->width) { + while (x < this->image.width) { if (header.imageType == 10) { const unsigned char packet = *source++; std::uint16_t count = (packet & 127) + 1; @@ -381,9 +381,9 @@ bool BitmapImage::DecodeTga(const void* input, int) { } } - row -= this->width; + row -= this->image.width; } - this->alpha = 1; + this->image.alpha = 1; return true; } diff --git a/Source/Resource/Bitmap/BitmapImage.h b/Source/Resource/Bitmap/BitmapImage.h index 53578d245..b42ecf664 100644 --- a/Source/Resource/Bitmap/BitmapImage.h +++ b/Source/Resource/Bitmap/BitmapImage.h @@ -16,13 +16,6 @@ struct BitmapImage { BitmapImage() : alpha(0), pixels(nullptr), auxiliary(nullptr) { } void Clear(); - bool CreateAuxiliary(int mode); - std::uint32_t Pixel(int x, int y) const; - void ClearAuxiliary(); - bool DecodeBitmap(const void* data, int bytes, bool iconOnly); - bool DecodeTga(const void* data, int bytes); - bool DecodePng(const void* data, int bytes, const char* name); - bool DecodeJpeg(const void* data, int bytes); }; // INLINED diff --git a/Source/Resource/Bitmap/BitmapImageJpeg.cpp b/Source/Resource/Bitmap/BitmapImageJpeg.cpp index 882aaa17b..5eace715f 100644 --- a/Source/Resource/Bitmap/BitmapImageJpeg.cpp +++ b/Source/Resource/Bitmap/BitmapImageJpeg.cpp @@ -1,11 +1,11 @@ -#include "Resource/Bitmap/BitmapImage.h" +#include "Resource/Bitmap/BitmapResource.h" #include "Resource/Bitmap/IJL15Runtime.h" #include // OFFSET: 0x0074BCC0 // FUNCTION: fn_07871 -bool BitmapImage::DecodeJpeg(const void* data, int bytes) { +bool CBitmapRes::DecodeJpeg(const void* data, int bytes) { IJL15Properties properties = {}; if (ijlInit(&properties) != 0) { return false; @@ -16,12 +16,12 @@ bool BitmapImage::DecodeJpeg(const void* data, int bytes) { unsigned char* source; if (ijlRead(&properties, 1) == 0) { - this->width = properties.jpegWidth; - this->height = properties.jpegHeight; + this->image.width = properties.jpegWidth; + this->image.height = properties.jpegHeight; source = new unsigned char[properties.jpegHeight * properties.jpegWidth * 3]; - this->pixels = new std::uint32_t[this->height * this->width]; - properties.dibWidth = this->width; - properties.dibHeight = this->height; + this->image.pixels = new std::uint32_t[this->image.height * this->image.width]; + properties.dibWidth = this->image.width; + properties.dibHeight = this->image.height; properties.dibBytes = source; properties.dibColor = 2; properties.dibChannels = 3; @@ -29,8 +29,8 @@ bool BitmapImage::DecodeJpeg(const void* data, int bytes) { if (ijlRead(&properties, 3) != 0) { delete[] source; - delete[] this->pixels; - this->pixels = nullptr; + delete[] this->image.pixels; + this->image.pixels = nullptr; return false; } @@ -40,14 +40,14 @@ bool BitmapImage::DecodeJpeg(const void* data, int bytes) { ijlFree(&properties); - for (int y = 0; y < this->height; ++y) { - std::uint32_t* out = &this->pixels[this->width * y]; - const unsigned char* input = &source[3 * this->width * y]; + for (int y = 0; y < this->image.height; ++y) { + std::uint32_t* out = &this->image.pixels[this->image.width * y]; + const unsigned char* input = &source[3 * this->image.width * y]; if (!input) { return false; } - for (int x = 0; x < this->width; ++x) { + for (int x = 0; x < this->image.width; ++x) { const unsigned red = input[2]; const unsigned blue = input[0]; const unsigned green = input[1]; @@ -57,6 +57,6 @@ bool BitmapImage::DecodeJpeg(const void* data, int bytes) { } delete[] source; - this->alpha = 0; + this->image.alpha = 0; return true; } diff --git a/Source/Resource/Bitmap/BitmapImagePng.cpp b/Source/Resource/Bitmap/BitmapImagePng.cpp index b7f584aa5..24a3de12e 100644 --- a/Source/Resource/Bitmap/BitmapImagePng.cpp +++ b/Source/Resource/Bitmap/BitmapImagePng.cpp @@ -1,4 +1,4 @@ -#include "Resource/Bitmap/BitmapImage.h" +#include "Resource/Bitmap/BitmapResource.h" #include #include @@ -25,7 +25,7 @@ namespace { // OFFSET: 0x0074BF10 // FUNCTION: fn_07872 -bool BitmapImage::DecodePng(const void* data, int bytes, const char*) { +bool CBitmapRes::DecodePng(const void* data, int bytes, const char*) { unsigned char signature[8] = {}; if (data) { std::memcpy(signature, data, sizeof(signature)); @@ -60,8 +60,8 @@ bool BitmapImage::DecodePng(const void* data, int bytes, const char*) { std::iostream stream(&buffer); png_set_read_fn(png, &stream, ReadPng); png_read_info(png, info); - this->width = png_get_image_width(png, info); - this->height = png_get_image_height(png, info); + this->image.width = png_get_image_width(png, info); + this->image.height = png_get_image_height(png, info); const unsigned colorType = png_get_color_type(png, info); const unsigned depth = png_get_bit_depth(png, info); png_set_interlace_handling(png); @@ -91,27 +91,27 @@ bool BitmapImage::DecodePng(const void* data, int bytes, const char*) { } png_read_update_info(png, info); - auto** rows = static_cast(std::malloc(sizeof(png_bytep) * static_cast(this->height))); + auto** rows = static_cast(std::malloc(sizeof(png_bytep) * static_cast(this->image.height))); - for (int y = 0; y < this->height; ++y) { + for (int y = 0; y < this->image.height; ++y) { rows[y] = static_cast(std::malloc(png_get_rowbytes(png, info))); } png_read_image(png, rows); - this->pixels = new std::uint32_t[this->width * this->height]; + this->image.pixels = new std::uint32_t[this->image.width * this->image.height]; - for (int y = 0; y < this->height; ++y) { + for (int y = 0; y < this->image.height; ++y) { const unsigned char* pixel = rows[y]; - std::uint32_t* out = &this->pixels[this->width * y]; - for (int x = 0; x < this->width; ++x) { + std::uint32_t* out = &this->image.pixels[this->image.width * y]; + for (int x = 0; x < this->image.width; ++x) { *out++ = (((((pixel[3] << 8) + pixel[0]) << 8) + pixel[1]) << 8) + pixel[2]; pixel += 4; } } - this->alpha = 1; + this->image.alpha = 1; - for (int y = 0; y < this->height; ++y) { + for (int y = 0; y < this->image.height; ++y) { std::free(rows[y]); } diff --git a/Source/Resource/Bitmap/BitmapResource.cpp b/Source/Resource/Bitmap/BitmapResource.cpp index 3791949be..53d749372 100644 --- a/Source/Resource/Bitmap/BitmapResource.cpp +++ b/Source/Resource/Bitmap/BitmapResource.cpp @@ -49,19 +49,19 @@ bool CBitmapRes::Decode(const char* name, const void* data, int bytes, bool icon } if (lstrcmpiA(extension, ".bmp") == 0) { - return this->image.DecodeBitmap(data, bytes, iconOnly); + return this->DecodeBitmap(data, bytes, iconOnly); } if (lstrcmpiA(extension, ".tga") == 0) { - return this->image.DecodeTga(data, bytes); + return this->DecodeTga(data, bytes); } if (lstrcmpiA(extension, ".jpg") == 0) { - return this->image.DecodeJpeg(data, bytes); + return this->DecodeJpeg(data, bytes); } if (lstrcmpiA(extension, ".png") == 0) { - return this->image.DecodePng(data, bytes, name); + return this->DecodePng(data, bytes, name); } ShowErrorDialog("Unsupport fileformat!", 0); diff --git a/Source/Resource/Bitmap/BitmapResource.h b/Source/Resource/Bitmap/BitmapResource.h index 8ba832a69..504efe6ce 100644 --- a/Source/Resource/Bitmap/BitmapResource.h +++ b/Source/Resource/Bitmap/BitmapResource.h @@ -26,6 +26,13 @@ public: bool Load(const char* name) override; void Unload() override; virtual bool Decode(const char* name, const void* data, int bytes, bool iconOnly); + bool CreateAuxiliary(int mode); + std::uint32_t Pixel(int x, int y) const; + void ClearAuxiliary(); + bool DecodeBitmap(const void* data, int bytes, bool iconOnly); + bool DecodeTga(const void* data, int bytes); + bool DecodePng(const void* data, int bytes, const char* name); + bool DecodeJpeg(const void* data, int bytes); /* 0110 */ BitmapImage image; }; diff --git a/Source/Resource/Bitmap/GifResource.cpp b/Source/Resource/Bitmap/GifResource.cpp index e2fcbe593..4fe5f2bfa 100644 --- a/Source/Resource/Bitmap/GifResource.cpp +++ b/Source/Resource/Bitmap/GifResource.cpp @@ -105,19 +105,19 @@ bool CGifRes::Decode(const char* name, const void* data, int bytes, bool iconOnl } if (lstrcmpiA(extension, ".bmp") == 0) { - return this->image.DecodeBitmap(data, bytes, iconOnly); + return this->DecodeBitmap(data, bytes, iconOnly); } if (lstrcmpiA(extension, ".tga") == 0) { - return this->image.DecodeTga(data, bytes); + return this->DecodeTga(data, bytes); } if (lstrcmpiA(extension, ".jpg") == 0) { - return this->image.DecodeJpeg(data, bytes); + return this->DecodeJpeg(data, bytes); } if (lstrcmpiA(extension, ".png") == 0) { - return this->image.DecodePng(data, bytes, name); + return this->DecodePng(data, bytes, name); } ShowErrorDialog("Unsupport fileformat!", 0); diff --git a/Source/Resource/Bitmap/SkinPalette.cpp b/Source/Resource/Bitmap/SkinPalette.cpp index e5ce46ed8..30e754893 100644 --- a/Source/Resource/Bitmap/SkinPalette.cpp +++ b/Source/Resource/Bitmap/SkinPalette.cpp @@ -8,7 +8,7 @@ std::uint32_t SkinPaletteColor(ResourceMgr& resources, const SkinPaletteCell& ce auto* bitmap = static_cast( resources.Load(resolveSkin ? Resolve("유저인터페이스\\colorchip.bmp") : "유저인터페이스\\colorchip.bmp")); if (bitmap) { - const std::uint32_t color = bitmap->image.Pixel(4 * cell.column + 2, 4 * cell.row + 2); + const std::uint32_t color = bitmap->Pixel(4 * cell.column + 2, 4 * cell.row + 2); return RGB((color >> 16) & 255, (color >> 8) & 255, color & 255); } return 0; @@ -24,7 +24,7 @@ std::uint32_t __stdcall SkinPaletteColor(const SkinPaletteCell& cell, bool resol // FUNCTION: fn_09685 void SkinPaletteChannels(ResourceMgr& resources, int x, int y, unsigned& red, unsigned& green, unsigned& blue) { auto* bitmap = static_cast(resources.Load(Resolve("유저인터페이스\\colorchip.bmp"))); - const std::uint32_t color = bitmap->image.Pixel(x, y); + const std::uint32_t color = bitmap->Pixel(x, y); red = (color >> 16) & 255; green = (color >> 8) & 255; blue = color & 255; diff --git a/Source/UI/Macro/UICaptchaPreviewWnd.cpp b/Source/UI/Macro/UICaptchaPreviewWnd.cpp index 1f47ae8b0..e5f8886dc 100644 --- a/Source/UI/Macro/UICaptchaPreviewWnd.cpp +++ b/Source/UI/Macro/UICaptchaPreviewWnd.cpp @@ -37,7 +37,7 @@ void UICaptchaPreviewWnd::AddImageData(const void* data, int size) { uLongf length = 0x9AB0; Bytef* image = new (std::nothrow) Bytef[0x9AB0]; uncompress(image, &length, this->m_imageData, this->m_imageReceived); - this->m_image->m_bitmap.image.DecodeBitmap(image, length, false); + this->m_image->m_bitmap.DecodeBitmap(image, length, false); if (image) { delete[] image; } @@ -56,7 +56,7 @@ void UIMacroDetectorWnd::AddImageData(const void* data, int size) { uLongf length = 0x9AB0; Bytef* image = new (std::nothrow) Bytef[0x9AB0]; uncompress(image, &length, this->m_imageData, this->m_imageReceived); - this->m_image->m_bitmap.image.DecodeBitmap(image, length, false); + this->m_image->m_bitmap.DecodeBitmap(image, length, false); if (image) { delete[] image; } diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 31a025861..ff8eccd00 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -815,23 +815,23 @@ void UIWindow::RemoveChild(UIWindow* child, unsigned char destroy) { // OFFSET: 0x00A81CC0 // FUNCTION: fn_16986 -bool UIWindow::Contains(const UIWindow* window) const { +int UIWindow::Contains(const UIWindow* window) const { if (!window) { - return false; + return 0; } if (window == this) { - return true; + return 1; } for (auto it = this->m_children.begin(); it != this->m_children.end(); ++it) { UIWindow* child = *it; if (child->Contains(window)) { - return true; + return 1; } } - return false; + return 0; } // OFFSET: 0x00A7B3F0 @@ -1208,10 +1208,10 @@ void UIWindow::DrawAuxiliaryScaled(int mode, int x, int y, int width, int height } if (rebuild) { - image->ClearAuxiliary(); + reinterpret_cast(image)->ClearAuxiliary(); } - image->CreateAuxiliary(mode); + reinterpret_cast(image)->CreateAuxiliary(mode); if (image->auxiliary) { this->geometry.surface->ScaleCopy(x, y, image->width, image->height, width, height, static_cast(image->auxiliary), option); } @@ -1225,10 +1225,10 @@ void UIWindow::DrawAuxiliary(int mode, int x, int y, BitmapImage* image, bool tr } if (rebuild) { - image->ClearAuxiliary(); + reinterpret_cast(image)->ClearAuxiliary(); } - image->CreateAuxiliary(mode); + reinterpret_cast(image)->CreateAuxiliary(mode); if (image->auxiliary) { this->geometry.surface->Copy(x, y, image->width, image->height, static_cast(image->auxiliary), transparent); } diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index 2f7770130..d6a91a9e1 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -101,7 +101,7 @@ public: void RemoveChild(UIWindow* child, unsigned char destroy); void InvalidateChildren(); - bool Contains(const UIWindow* window) const; + int Contains(const UIWindow* window) const; bool IsDescendantOf(const UIWindow* ancestor) const; void BroadcastMsg4(); void BroadcastMsg3();