From f3f0f4d15f76d1007b6a6ba95f61d0848f7d6073 Mon Sep 17 00:00:00 2001 From: chirsz-ever Date: Mon, 31 Aug 2020 14:37:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(graphics):=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=20?= =?UTF-8?q?`initgraph`=20=E5=89=8D=E8=B0=83=E7=94=A8=20`getimage`=20?= =?UTF-8?q?=E6=97=B6=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `getimage_from_IPicture` 函数使用全局 DC,现改为使用 `::GetDC(NULL)` 获取 --- src/image.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index ddf6bf48..5076afc8 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -317,12 +317,15 @@ IMAGE::getimage(LPCSTR filename, int zoomWidth, int zoomHeight) { inline void getimage_from_IPicture(PIMAGE self, IPicture* pPicture) { long lWidth, lHeight, lWidthPixels, lHeightPixels; - PIMAGE img = CONVERT_IMAGE_CONST(0); - pPicture->get_Width (&lWidth ); - lWidthPixels = MulDiv(lWidth, GetDeviceCaps(img->m_hDC, LOGPIXELSX), 2540); - pPicture->get_Height(&lHeight); - lHeightPixels = MulDiv(lHeight, GetDeviceCaps(img->m_hDC, LOGPIXELSY), 2540); - CONVERT_IMAGE_END; + { + ::HDC ScreenDC = ::GetDC(NULL); + pPicture->get_Width (&lWidth); + pPicture->get_Height(&lHeight); + // convert Himetric units to pixels + lWidthPixels = ::MulDiv(lWidth, ::GetDeviceCaps(ScreenDC, LOGPIXELSX), 2540); + lHeightPixels = ::MulDiv(lHeight, ::GetDeviceCaps(ScreenDC, LOGPIXELSY), 2540); + ::ReleaseDC(NULL, ScreenDC); + } self->resize(lWidthPixels, lHeightPixels); {