<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-GB link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hi list,<o:p></o:p></p>
<p class=MsoNormal>I’m writing a source filter for <a
href="http://en.wikipedia.org/wiki/DirectShow">DirectShow</a> <span
style='color:#1F497D'>on the win32 platform </span>and I’m hoping to use Cairo
to generate simple overlay graphics for a video feed.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The source filter generates media frames (bitmaps).
For each frame, I have the following code:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>// I have the following member variables created:<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>cairo_surface_t * m_pSurface;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>cairo_t
* m_pCR;<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>// and I create the surface like
so:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>m_pSurface
= cairo_win32_surface_create_with_dib( cairoFmt, m_nImageWidth, m_nImageHeight
);</span><span style='color:#1F497D'><o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>// the drawing function<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console";color:blue'>void</span><span style='font-size:
10.0pt;font-family:"Lucida Console"'> SrcOutPin::DrawFrame( BYTE* pData, LONG
lDataLen )<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>{ <o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> <span
style='color:blue'>char</span>
szTime [50];<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
SYSTEMTIME
tmCurrentTime; <o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
GetLocalTime(&tmCurrentTime);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> <span
style='color:green'>// clear the surface to transparent
<o:p></o:p></span></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_save(m_pCR); <o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_set_operator( m_pCR, CAIRO_OPERATOR_CLEAR );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_paint(m_pCR);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_restore(m_pCR);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> <span
style='color:green'>// write the time <o:p></o:p></span></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> _snprintf( <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console"'>szTime, <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console"'>50, <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console";color:#A31515'>"%.2d:%.2d:%.2d\0"</span><span
style='font-size:10.0pt;font-family:"Lucida Console"'>, <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console"'>tmCurrentTime.wHour,
<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console"'>tmCurrentTime.wMinute,
<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt;text-autospace:
none'><span style='font-size:10.0pt;font-family:"Lucida Console"'>tmCurrentTime.wSecond
<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt;text-autospace:none'><span
style='font-size:10.0pt;font-family:"Lucida Console"'>);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_set_source_rgba( m_pCR, 0.0, 0.0, 0.0, 1.0 );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_select_font_face ( m_pCR, <span style='color:#A31515'>"Sans"</span>,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_set_font_size ( m_pCR, 14.0 );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> cairo_move_to (
m_pCR, 40.0, 40.0 );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> cairo_show_text (
m_pCR, szTime );<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'>
cairo_paint(m_pCR);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console"'> <span
style='color:green'>// TODO: copy the cairo surface data into the sample buffer<o:p></o:p></span></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Lucida Console";color:green'> // I
imagine this might be a memcpy() call from source to pData<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt;text-autospace:none'><span
style='font-size:10.0pt;font-family:"Lucida Console"'>memcpy((void*)pData,
(void*)???, lDataLen);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>I’d
seen <a href="http://www.cairographics.org/FAQ/#paint_from_a_surface">the
section in the FAQ</a> on painting from one surface to another, but I’m just
guessing and I’m not sure that this would be suitable. Can someone show
me the correct procedure?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>thanks,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console"'>john</span><o:p></o:p></p>
</div>
</body>
</html>