[cairo] Problem with printing

Patrik Mueller Paddi.M at gmx.net
Sat Jan 21 17:53:25 PST 2006


Hi all,

I have a problem with printing with Cairo 1.02 and Windows XP:
At a MFC view and inside a print preview everything looks ok. But if I 
print the cairo surface I have some black rectangles inside the print 
(for example when printing arcs or when some paths are rotated).
I think the problem is the alpha content. Is there a simple way to 
rebuild a Win32 surface without the alpha content?

Heres my actual code:

		cairo_surface_t *surface;
		cairo_t *cr;

		surface = cairo_win32_surface_create (pDC->GetSafeHdc());
		cr = cairo_create (surface);

		m_Cairo.SetContext(cr);
				
		CRect tmpRect;
		GetClientRect(tmpRect);
		
		int minX = tmpRect.left;
		int maxX = tmpRect.right;
		int minY = tmpRect.top;
		int maxY = tmpRect.bottom;
		
		m_Cairo.SetBackgroundType(ccRenderer2D::BG_GRADIENT);
		m_Cairo.SetBGColorTop(cclab::ccGeomColor(160,160,160));
		m_Cairo.SetBGColorBottom(cclab::ccGeomColor(0,0,0));

		if (pDC->IsPrinting())
		{
			maxX = pDC->GetDeviceCaps(HORZRES);
			maxY = pDC->GetDeviceCaps(VERTRES);
			if (!GetPrintBG())
			{
				m_Cairo.SetBackgroundType(ccRenderer2D::BG_NONE);
				m_Cairo.SetBGColorTop(cclab::ccGeomColor(255,255,255));
			}
		}
		m_Cairo.GetViewPort()->Init();
		m_Cairo.GetViewPort()->AddX(minX);
		m_Cairo.GetViewPort()->AddX(maxX);
		m_Cairo.GetViewPort()->AddY(minY);
		m_Cairo.GetViewPort()->AddY(maxY);

		m_Cairo.SetScaleFactor(1.0);
		m_Cairo.Draw(GetDocument()->GetScene2D());

		if (m_writeDebugPng)
			cairo_surface_write_to_png(surface, "c:\\cairoview.png");

		m_Cairo.SetContext(NULL);

		cairo_restore (cr);

		cairo_destroy (cr);
		cairo_surface_destroy (surface);


Thanks for any hints,

Patrik



More information about the cairo mailing list