[cairo] EMF output?

Hans Breuer hans at breuer.org
Mon Feb 26 23:34:20 PST 2007


On 26.02.2007 00:29, Vladimir Vukicevic wrote:
> Jan Struyf wrote:
>>
>> Dear All,
>>
>> I would like to use the Cairo library save graphs, diagrams and
>> technical drawings in various vector and possibly bitmap formats.
>> Besides SVG and PDF output, I'm also very much interested in EMF
>> because this would allow me to copy and paste graphics to various
>> Windows applications.
>>
>> I was wondering if the Win32 surface is useful for this. Is this a
>> bitmap surface or is it really a vector surface? Given that I'm mainly
>> interested in this for technical drawings, saving in vector format is
>> important, even if not all effects are perfectly rendered in this way.
> 
This is the exact use case I had in mind with my WMF/EMF backend. It was
tested in Dia ( http://www.gnome.org/projects/dia and
http://svn.gnome.org/viewcvs/dia/trunk/plug-ins/cairo/diacairo.c?view=markup )

> Are you sure?  Saving in EMF/PDF isn't all that useful, because it's
> very hard to modify the data afterwards.  Unless you're talking about
> just saving for output only, in which case PDF would be far superior
> than EMF for that purpose.  The only thing that you'd lose is the
> ability to move EMF/vector data using the clipboard; 
I tend to disagree. You not only loose the ability to exchange vectors (or
better meta, because EMF can contain bitmaps as well) via clipboard but
also the ability to appropriately feed GDI printers. At the moment the only
thing cairo can do is printing a huge bitmap 'natively'.

See http://hans.breuer.org/dia/dia-cairo.htm for afeature comparsion.

> I'm honestly not
> aware of too many apps that can do something useful with that, other
> than, say, pasting an EMF into a word processing document.
> 
Which may not be of interest for stuff from a browser but can be a show
stopper for a vector drawing program.

>> I found a thread about a patch contributed by Hans Breuer and it
>> appears that this patch is related to my question because it defines
>> vector operations for EMF output:
>>
>> <http://lists.freedesktop.org/archives/cairo/2005-February/002936.html>
>>
I like mailing list archives ;)

>> Has this patch or similar functionality been integrated into Cairo? Or
>> is this still a difficult matter? I understood that there is a balance
>> between approximating the intended drawing with the supported
>> primitives by the target format or rendering parts of the drawing as a
>> bitmap and that this is especially difficult for EMF.
> 
> To support EMF rendering, you'd pretty much need a completely new win32
> surface that's expressly for EMF rendering; 
This is what the patch did ...

> it would need to hook into a
> different layer of the cairo stack to be able to do it.  
Yes, nowadays the WMF/EMF backend would need to use the cairo meta surface.
But it was not available when I originally wrote the backend.

> A GDI+ surface
> might be useful for this, since (I believe?) you can render to a
> metafile using GDI+ but I'm not positive.  I'm not sure about that patch
> from 2005; there is a current win32 surface which is GDI only, renders
> to bitmaps, and accelerates what it can using GDI functions and hands
> the rest to fallback code.
> 
Just read the old thread than. One of my main points was that only one
win32 surface may not be enough. Not only for vector exchange with other
programs but also to reach cairo's qulaity-printing goal on win32.

Every printer (driver) on windows understands Windows (Enhanced) Metafile,
some do understand PostScript but I'm not aware of a printer understanding
PDF 'natively'.

Regards,
	Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert


More information about the cairo mailing list