Original post address
Http://mqjing.blogspot.com/2007/12/directshow.html
PWC is Pointer of ccomptr <ivmrwindowlesscontrol>
# Define bft_bitmap 0x4d42 // 'bm'
# Define dibnumcolors (lpbi)-> biclrused = 0 & (lpbi)-> bibitcount <= 8/
? (INT) (1 <(INT) (lpbi)-> bibitcount )/
: (INT) (lpbi)-> biclrused)
# Define dibsize (lpbi)-> bisize + (lpbi)-> bisizeimage + (INT) (lpbi)-> biclrused * sizeof (rgbquad ))
# Define dibpalettesize (lpbi) (dibnumcolors (lpbi) * sizeof (rgbquad ))
Void cedvrplayer: onbnclickedbutton2 (){
Hresult hr;
Tchar * szfile = _ T ("C: // test.bmp ");
// Capture strongswan
Byte * lpdib = NULL;
HR = PwC-> getcurrentimage (& lpdib );
If (succeeded (HR )){
Bitmapfileheader HDR;
DWORD dwsize, dwwritten;
Lpbitmapinfoheader pdib = (lpbitmapinfoheader) lpdib;
// Create a new file to store the bitmap data
Handle hfile = createfile (szfile, generic_write, file_assist_read, null,
Create_always, file_attribute_normal, 0 );
If (hfile = invalid_handle_value)
Return;
// Initialize the Bitmap header
Dwsize = dibsize (pdib );
HDR. bftype = bft_bitmap;
HDR. bfsize = dwsize + sizeof (bitmapfileheader );
HDR. bfreserved1 = 0;
HDR. bfreserved2 = 0;
HDR. bfoffbits = (DWORD) sizeof (bitmapfileheader) + pdib-> bisize +
Dibpalettesize (pdib );
// Write the Bitmap header and bitmap bits to the file
Writefile (hfile, (lpcvoid) & HDR, sizeof (bitmapfileheader), & dwwritten, 0 );
Writefile (hfile, (lpcvoid) pdib, dwsize, & dwwritten, 0 );
// Close the file
Closehandle (hfile );
Cotaskmemfree (lpdib );
}
// End of capture always writable