|
-
May 31st, 2016, 02:41 PM
#1
Issue with playing metafile to device context then saving to bitmap. What I missing?
Long day. Sure I'm missing something simple. Anyway, I have a valid old school metafile (not enhanced metafile) in the form of a LPMETAFILEPICT. It's valid and everything looks good.
What I'm trying to do is save it to a bitmap. On my first try, I play it to the device context and get a black box. OK, I read somewhere on google to play the metafile on to a white bitmap. I fill the bitmap w/ white and I still get a black box. This should be simple, and maybe I'm missing something dumb.
Can anyone point me the right direction? (This is a console app, btw)
Here's what I'm doing:
Code:
HDC hdc = CreateCompatibleDC(NULL); // NULL = Display DC.
CDC* pdc = CDC::FromHandle(hdc);
CRect r = new CRect(100, 170, 270, 230);
CDC memDC;
memDC.CreateCompatibleDC(pdc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pdc, r.Width(), r.Height());
CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
memDC.FillSolidRect(r, RGB(255, 255, 255)); // Fill bitmap w/ white(?)
memDC.PlayMetaFile(pMetaPict->hMF); // my LPMETAFILEPICT
pdc->BitBlt(r.left, r.top, r.right - r.left, r.bottom - r.top, &memDC, r.left, r.top, SRCCOPY);
CImage img;
img.Attach((HBITMAP)bitmap.Detach());
img.Save(_T("C:\\savedBitmap.bmp"), Gdiplus::ImageFormatBMP);
All I get is a black box.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|