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 68c4a38
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,29 +775,40 @@ PyImaging_DrawWmf(PyObject *self, PyObject *args) {

void *ptr;
bitmap = CreateDIBSection(dc, &info, DIB_RGB_COLORS, &ptr, NULL, 0);
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;
HENHMETAFILE hEmf = GetEnhMetaFile("test.emf");
if (hEmf)
{
ENHMETAHEADER pEmfHeader;
if (GetEnhMetaFileHeader(hEmf, sizeof(pEmfHeader), &pEmfHeader) != 0)
{
// 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(dc, bitmap);
if (!PlayEnhMetaFile(dc, 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 68c4a38

Please sign in to comment.