diff --git a/Source/Render/DeviceContext/DCBitmap.h b/Source/Render/DeviceContext/DCBitmap.h index 2563fd5b..5cbaf39b 100644 --- a/Source/Render/DeviceContext/DCBitmap.h +++ b/Source/Render/DeviceContext/DCBitmap.h @@ -39,6 +39,7 @@ public: void Brighten(int x, int y, int width, int height, int amount) override; void Dim(int x, int y, int width, int height, int percent) override; void UploadTexture(CRenderSystemBase& system, CTexture*& texture); + HGDIOBJ Create(int width, int height); // INLINED void SetAlpha(bool alpha) { this->m_cache.m_alpha = alpha; diff --git a/Source/Render/Textures/BitmapPixels.cpp b/Source/Render/Textures/BitmapPixels.cpp index 26ec3f8c..66959899 100644 --- a/Source/Render/Textures/BitmapPixels.cpp +++ b/Source/Render/Textures/BitmapPixels.cpp @@ -1,3 +1,4 @@ +#include "Render/DeviceContext/DCBitmap.h" #include "Render/Textures/BitmapPixels.h" #include "Render/RenderSystemBase.h" #include "Render/Textures/SpriteAtlas.h" @@ -67,6 +68,35 @@ void BitmapPixels::Create(int newWidth, int newHeight) { this->previous = SelectObject(this->dc, this->bitmap); } +// FUNCTION: fn_01845 +HGDIOBJ CDCBitmap::Create(int width, int height) { + this->m_bitmap.width = width; + this->m_bitmap.dirty = true; + this->m_bitmap.height = height; + this->m_cache.Clear(); + + BITMAPINFO info; + info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info.bmiHeader.biWidth = this->m_bitmap.width; + info.bmiHeader.biHeight = -static_cast(this->m_bitmap.height); + info.bmiHeader.biPlanes = 1; + info.bmiHeader.biBitCount = 32; + info.bmiHeader.biCompression = BI_RGB; + info.bmiHeader.biSizeImage = 0; + info.bmiHeader.biXPelsPerMeter = 100; + info.bmiHeader.biYPelsPerMeter = 100; + info.bmiHeader.biClrUsed = 0; + info.bmiHeader.biClrImportant = 0; + this->m_bitmap.bitmap = CreateDIBSection(nullptr, &info, DIB_RGB_COLORS, reinterpret_cast(&this->m_bitmap.pixels), nullptr, 0); + + if (!this->m_bitmap.bitmap) { + this->m_bitmap.pixels = nullptr; + } + + this->m_bitmap.previous = SelectObject(this->m_bitmap.dc, this->m_bitmap.bitmap); + return this->m_bitmap.previous; +} + // OFFSET: 0x00547D40 // FUNCTION: fn_01850 void BitmapPixels::Grow(std::uint32_t newWidth, std::uint32_t newHeight) {