Skip to content

Commit

Permalink
nextcomment
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 9, 2024
1 parent e42aa0e commit abf4f14
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,26 +778,40 @@ PyImaging_DrawWmf(PyObject *self, PyObject *args) {
SelectObject(dc, bitmap);

HENHMETAFILE hemf = GetEnhMetaFile("test.emf");
if (hemf == NULL) {
printf("getenh fail\n");
} else {
printf("getenh pass\n");
}

RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = 14030;
rect.bottom = 9920;

if (!PlayEnhMetaFile(dc, hemf, &rect)) {
printf("error %d\n", GetLastError());
printf("hit\n");

PyErr_SetString(PyExc_OSError, "cannot render metafile");
goto error;
if (hEmf)
{
ENHMETAHEADER pEmfHeader;
if (GetEnhMetaFileHeader(hEmf, sizeof(pEmfHeader), &pEmfHeader) != 0)
{
HDC hDC = GetDC(hWnd);

// For test
RECT rcBounds;
rcBounds.left = MulDiv(pEmfHeader.rclFrame.left, pEmfHeader.szlDevice.cx, pEmfHeader.szlMillimeters.cx * 100);
rcBounds.top = MulDiv(pEmfHeader.rclFrame.top, pEmfHeader.szlDevice.cy, pEmfHeader.szlMillimeters.cy * 100);
rcBounds.right = MulDiv(pEmfHeader.rclFrame.right, pEmfHeader.szlDevice.cx, pEmfHeader.szlMillimeters.cx * 100);
rcBounds.bottom = MulDiv(pEmfHeader.rclFrame.bottom, pEmfHeader.szlDevice.cy, pEmfHeader.szlMillimeters.cy * 100);
int nWidth = rcBounds.right - rcBounds.left;
int nHeight = rcBounds.bottom - rcBounds.top;

BITMAPINFO BitmapInfo;
ZeroMemory(&BitmapInfo, sizeof(BITMAPINFO));
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BitmapInfo.bmiHeader.biWidth = nWidth;
BitmapInfo.bmiHeader.biHeight = nHeight;
BitmapInfo.bmiHeader.biPlanes = 1;
BitmapInfo.bmiHeader.biBitCount = 32;
BitmapInfo.bmiHeader.biCompression = BI_RGB;
RECT rect;
GetClientRect(hWnd, &rect);
SelectObject(hDC, bitmap);
if (!PlayEnhMetaFile(hDC, hEmf, &rect)) {
printf("failit\n");
} else {
printf("passit\n");
}
}
}

COLORREF color = GetPixel(dc, 200, 200);
printf("rgb %d %d %d\n", GetRValue(color), GetGValue(color), GetBValue(color));

Expand Down

0 comments on commit abf4f14

Please sign in to comment.