[Gtk-sharp-list] How much metafiles are really supported in Mono?

romeok romeok at rosvet.com
Mon Dec 29 05:50:27 EST 2008

We are developers of Aspose.Words, it is a .NET component for
programmatically working with documents, conversions, report generation in
popular word processing formats.

>From time to time we test Aspose.Words with Mono and we state that
Aspose.Words can run on Mono and there is interest from our customers for

One of the features we have is conversion from DOC/OOXML/RTF to HTML.
Microsoft Word documents can contain EMF or WMF metafiles, but when saving
to HTML we normally render them to a raster image and save in a more
suitable format, such as PNG (because metafiles are not really welcome in

To convert a metafile to a raster image on .NET we just use
Graphics.DrawImage that plays a metafile on a graphics object of a desired
size and resolution and then we just save to PNG.

I read somewhere that in Mono 2.0 metafiles are somewhat supported and can
be rendered to graphics. However, upon trying to do that I always get an
exception stating something in Graphics.DrawImage is not supported.

Upon inspection of the code I can see the following piece in image.c in

	if (image->type == ImageTypeBitmap) {		if (gdip_is_an_indexed_pixelformat
(image->active_bitmap->pixel_format)) {
			GpStatus status = OutOfMemory;
			GpBitmap *rgb_bitmap = gdip_convert_indexed_to_rgb (image);
			if (rgb_bitmap) {
				status = GdipDrawImageRectRect (graphics, rgb_bitmap,
					dstx, dsty, dstwidth, dstheight,
					srcx, srcy, srcwidth, srcheight,
					srcUnit, imageAttributes, callback, callbackData);
				GdipDisposeImage (rgb_bitmap);

			return status;
	} else {
		/* metafile support */
		return NotImplemented;

The highlighted code really looks like a bug in Mono to me. If you state
that metafiles can be rendered, then this code contradicts that statement.

So what is the state of metafile rendering and is it going to improve?

View this message in context: http://www.nabble.com/How-much-metafiles-are-really-supported-in-Mono--tp21201556p21201556.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

More information about the Gtk-sharp-list mailing list