Skip to content

Commit

Permalink
Merge pull request #41 from chirsz-ever/fix-getimage-from-ipc-2008
Browse files Browse the repository at this point in the history
fix(graphics): 修复在 `initgraph` 前调用 `getimage` 时出错
  • Loading branch information
wysaid authored Aug 31, 2020
2 parents 2bc0650 + f3f0f4d commit 40bca13
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
{
Expand Down

0 comments on commit 40bca13

Please sign in to comment.