[DirectShow] capture Samples

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.