DirectShow video line and output text

Source: Internet
Author: User

 

For convenience, it is directly displayed on the video, without dynamic output text and moving the line with the mouse, but it is the same principle, but dynamic needs to capture the mouse status message

Long CX, Cy; hresult hr; HR = PwC-> getnativevideosize (& CX, & cy, null, null); If (failed (HR )) {MSG (text ("getnativevideosize failed! HR = 0x % x \ r \ n "), HR); Return hr;} HDC = getdc (hwndapp); HDC hdcbmp = createcompatibledc (HDC ); g_hfont = createfont (30, 10, 0, 0, 10, false, default_charset, out_default_precis, clip_default_precis, default_quality, default_pitch, _ T (" ")); hfont holdfont = (hfont) SelectObject (hdcbmp, g_hfont); Hpen = createpen (ps_solid, 1, RGB (255, 0, 0); Hpen holdpen = (Hpen) SelectObject (hdcbmp, hpen); int nlength, Ntextbmpwidth, ntextbmpheight; size SZ = {0}; nlength = (INT) _ tcslen (sznewtext); gettextextentpoint32 (hdcbmp, sznewtext, nlength, & sz); ntextbmpheight =. cy; ntextbmpwidth = 400/* Sz. CX */; hbitmap HBM = createcompatiblebitmap (HDC, ntextbmpwidth, callback); releasedc (hwndapp, HDC); bitmap bm; hbitmap hbmold; GetObject (HBM, sizeof (BM ), & BM); hbmold = (hbitmap) SelectObject (hdcbmp, HBM); rect rctext; setre CT (& rctext, 0, 0, ntextbmpwidth, ntextbmpheight); setbkmode (hdcbmp, transparent); // set the transparent background settextcolor (hdcbmp, g_rgbcolors ); // text color: hbrush = (hbrush) getstockobject (null_brush); SelectObject (hdcbmp, hbrush); // draw a picture on the in-place graph // output text // textout (hdcbmp, 0, 0, sznewtext, nlength); drawtext (hdcbmp, sznewtext, sizeof (sznewtext), & rctext, dt_right); // draw lines movetoex (hdcbmp, 10, 10, null ); lineto (hdcbmp, 200,10); // ellipse (hdcb MP, 0, 0, 100, ntextbmpheight); // configure the vmr's bitmap structurevmralphabitmap BMP Info; zeromemory (& BMP info, sizeof (BMP info); BMP info. dwflags = vmrbitmap_hdc; BMP info. HDC = hdcbmp; g_nimagewidth = BM. bmwidth; g_fbitmapcompwidth = (float) g_nimagewidth/(float) CX; BMP info. rdest. left = 0.0f + x_edge_buffer; BMP info. rdest. right = 1.0f-x_edge_buffer; BMP info. rdest. top = (float) (Cy-BM. bmheight)/(flo At) cy-y_edge_buffer; BMP info. rdest. bottom = 1.0f-y_edge_buffer; BMP info. rsrc = rctext; BMP info. falpha = transparency_value; setcolorref (BMP info); HR = pbmp-> setalphabitmap (& BMP info); If (failed (HR) MSG (text ("setalphabitmap failed! HR = 0x % x \ r \ n % s \ 0 "), HR, str_vmr_display_warning ); // select the initial objects back into our device contextdeleteobject (SelectObject (hdcbmp, hbmold); deleteobject (SelectObject (hdcbmp, holdpen); SelectObject (HDC, holdfont ); deleteobject (HBM); deletedc (hdcbmp); Return hr;

 

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.