-
January 19th, 2023, 03:16 AM
#1
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
-
January 19th, 2023, 03:54 AM
#2
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"?
Victor Nijegorodov
-
January 20th, 2023, 05:26 AM
#3
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
-
January 20th, 2023, 06:50 AM
#4
Re: Get a *.bmp file of a window´s view
What about using the CImage class?
Victor Nijegorodov
-
January 20th, 2023, 08:37 AM
#5
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".
Last edited by ovidiucucu; January 21st, 2023 at 06:46 AM.
-
January 24th, 2023, 04:37 AM
#6
Re: Get a *.bmp file of a window´s view
Thank you!!!
I´ll try.
It´s great
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
|