Get a *.bmp file of a window´s view
I need to obtain a *.bmp file from a window ´s view in order to insert in a document.
Now i obtain this in a *.wmf file. But if I have a lot of wmf files and insert them in a document, the word file lats a lot of time when i open it.
My options are obtain the wmf file and convert it in a bmp file, or obtain the image directly in bmp file.
I´m working in Visual C++.
Is there a good way of do this?.
Thank you!
PERE
Re: Get a *.bmp file of a window´s view
What do you mean by "a *.bmp file from a window ´s view"?
Is it a screenshot? Or what?
Also how do you "obtain this in a *.wmf file"?
Re: Get a *.bmp file of a window´s view
"obtain this in a *.wmf file" :
I take a compatible CDC of my wimdow an associate this yto the window. I draw the content and save in a CMetafile object.
With this i can save in a .wmf file
Re: Get a *.bmp file of a window´s view
What about using the CImage class?
Re: Get a *.bmp file of a window´s view
As Victor already suggested, an easy way to save a bitmap in a file is by using CImage MFC/ATL-shared class.
Here is a simplified example which saves the client area of a window (view).
Code:
void CChildView::OnFileSave()
{
// get client rectangle and DC
CRect rc;
GetClientRect(rc);
CClientDC dc(this);
// create CImage object containing a 32 BPP bitmap
CImage img;
img.Create(rc.Width(), rc.Height(), 32);
// copy bitmap from client DC to image DC
::BitBlt(img.GetDC(), 0, 0, rc.Width(), rc.Height(), dc.m_hDC, 0, 0, SRCCOPY);
// save bitmap in a file
img.Save(_T("c:\\work\\test.bmp"), Gdiplus::ImageFormatBMP);
// release image DC
img.ReleaseDC();
}
Of course, you can modify it to get rid of hard-coded stuff, to handle errors, to let user to choose output folder, file name and format, which can be also JPEG, GIF or PNG. So far, forget that "CMetafile". :)
Re: Get a *.bmp file of a window´s view
Thank you!!!
I´ll try.
It´s great