Skip to content

Commit

Permalink
EGE/src/ege/image.cpp: 函数 getimage 支持在通过函数 initgraph 初始化前调用。
Browse files Browse the repository at this point in the history
参见 wysaid/xege#41 。

Signed-off-by: FrankHB <[email protected]>
  • Loading branch information
FrankHB committed Jan 20, 2024
1 parent 4b01b13 commit 6e8a0d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 时实现已支持调用。

  兼容实现调整:

Expand Down
13 changes: 7 additions & 6 deletions EGE/src/ege/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});
Expand Down

0 comments on commit 6e8a0d3

Please sign in to comment.