[cairo] copy cairo surface content to a bitmap
John McCullough
john at cobainltd.com
Thu Feb 18 01:37:46 PST 2010
Hi list,
I'm writing a source filter for DirectShow<http://en.wikipedia.org/wiki/DirectShow> on the win32 platform and I'm hoping to use Cairo to generate simple overlay graphics for a video feed.
The source filter generates media frames (bitmaps). For each frame, I have the following code:
// I have the following member variables created:
cairo_surface_t * m_pSurface;
cairo_t * m_pCR;
// and I create the surface like so:
m_pSurface = cairo_win32_surface_create_with_dib( cairoFmt, m_nImageWidth, m_nImageHeight );
// the drawing function
void SrcOutPin::DrawFrame( BYTE* pData, LONG lDataLen )
{
char szTime [50];
SYSTEMTIME tmCurrentTime;
GetLocalTime(&tmCurrentTime);
// clear the surface to transparent
cairo_save(m_pCR);
cairo_set_operator( m_pCR, CAIRO_OPERATOR_CLEAR );
cairo_paint(m_pCR);
cairo_restore(m_pCR);
// write the time
_snprintf(
szTime,
50,
"%.2d:%.2d:%.2d\0",
tmCurrentTime.wHour,
tmCurrentTime.wMinute,
tmCurrentTime.wSecond
);
cairo_set_source_rgba( m_pCR, 0.0, 0.0, 0.0, 1.0 );
cairo_select_font_face ( m_pCR, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD );
cairo_set_font_size ( m_pCR, 14.0 );
cairo_move_to ( m_pCR, 40.0, 40.0 );
cairo_show_text ( m_pCR, szTime );
cairo_paint(m_pCR);
// TODO: copy the cairo surface data into the sample buffer
// I imagine this might be a memcpy() call from source to pData
memcpy((void*)pData, (void*)???, lDataLen);
}
I'd seen the section in the FAQ<http://www.cairographics.org/FAQ/#paint_from_a_surface> 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?
thanks,
john
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20100218/e3091fbf/attachment.html
More information about the cairo
mailing list