From 6e8a0d3db3c5861c2d45edeb0f8c659384c47b00 Mon Sep 17 00:00:00 2001 From: FrankHB Date: Sun, 21 Jan 2024 02:06:09 +0800 Subject: [PATCH] =?UTF-8?q?EGE/src/ege/image.cpp:=20=E5=87=BD=E6=95=B0=20g?= =?UTF-8?q?etimage=20=E6=94=AF=E6=8C=81=E5=9C=A8=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=87=BD=E6=95=B0=20initgraph=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=89=8D=E8=B0=83=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 参见 https://github.com/wysaid/xege/pull/41 。 Signed-off-by: FrankHB --- ChangeLog.md | 3 +++ EGE/src/ege/image.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c0ab4835..8110f899 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -108,6 +108,9 @@ * 参见 [wysaid/xege pull request 30](https://github.com/wysaid/xege/pull/30) 。 * 修复函数 `setlinestyle` 、`setfillstyle` 、`setcolor` 、`setbkcolor` 、`setbkcolor_f` 、`setfontbkcolor` 、`floodfill` 和 `floodfillsurface` 的实现没有忽略 alpha 值。 * 参见 [wysaid/xege pull request 29](https://github.com/wysaid/xege/pull/29) 。 +* 函数 `getimage` 支持在通过函数 `initgraph` 初始化前调用。 + * 参见 [wysaid/xege pull request 41](https://github.com/wysaid/xege/pull/41) 。 + * 使用 YEGE 时实现已支持调用。   兼容实现调整: diff --git a/EGE/src/ege/image.cpp b/EGE/src/ege/image.cpp index baa2dcde..459365bb 100644 --- a/EGE/src/ege/image.cpp +++ b/EGE/src/ege/image.cpp @@ -464,16 +464,17 @@ graphics_errors IMAGE::getimage_b(void* p_pic) { auto& pic(*static_cast<::IPicture*>(p_pic)); - auto& img(get_pages().get_target_ref()); long lWidth, lHeight; - long lWidthPixels, lHeightPixels; pic.get_Width(&lWidth); - lWidthPixels - = ::MulDiv(lWidth, ::GetDeviceCaps(img.m_hDC, LOGPIXELSX), 2540); pic.get_Height(&lHeight); - lHeightPixels - = ::MulDiv(lHeight, ::GetDeviceCaps(img.m_hDC, LOGPIXELSY), 2540); + + const auto sdc(::GetDC({})); + const long lWidthPixels(::MulDiv(lWidth, ::GetDeviceCaps(sdc, LOGPIXELSX), + 2540)), lHeightPixels( + ::MulDiv(lHeight, ::GetDeviceCaps(sdc, LOGPIXELSY), 2540)); + + ::ReleaseDC({}, sdc); Resize(lWidthPixels, lHeightPixels); pic.Render(m_hDC, 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, {});