Jump to navigation

Poupou's Corner of the Web

Looking for perfect security? Try a wireless brick.
Otherwise you may find some unperfect stuff here...

Weblog

Feeding the monkeys

Work continues on the WMF parser. Things looks a lot better than last week (good sign). It's surprising what you can get from a few, but well choosen, record types. So far it proves the 80-20 rule. Here are two other samples I got from the old, but downloadable, OpenClipArt.org cliparts. Both are WMF metafiles, like my previous telescope sample. Both are mostly correct, except for the over filled text areas. Note the nice effect on the apple surface. WMF is an old 16bits technology so this is done by drawing multiple lines with different colors. Simple and surprising (at least the first time) as you know there's no code to do that ;-)

 
Seriously I couldn't blog them before I got colors working ;-)

Sadly it seems that EMF, EMF+ (using GDI+ functions) and EMF dual (having both) files are harder to find (none are in the OpenClipArt archive). Generating them myself feels like kind of cheating... and not very good test cases. Got some ? please email me!

On a totally unrelated news I finally (because not available in Canada) got my N800 thanks to the discount code (not available from Canada) and a friend. More on that soon...


2/26/2007 20:01:22 | Comments | Permalink

Metafiles

Today the biggest, API wise, missing feature in libgdiplus are metafiles. Just like the handling of icons, metafile support exists in several ways in GDI+.

First we have the System.Drawing.Imaging.Metafile class, which supports both the older (16bits) WMF and the newer (32bits) EMF formats (each one having some subformats to deal with). Unlike the Icon class Metafile inherits from the System.Drawing.Image class, so you can use them pretty much like any Bitmap, including the 30 overloads of Graphics.DrawImage method.

Beside being very badly documented, this class design is also kind of surprising. It has nearly different 40 constructors to allow playing or recording a metafile. Add to that (only) seven methods, including five overloads to get the metafile's header MetafileHeader, one to get the HENHMETAFILE handle and one to replay records (not the whole metafile) and you complete the class.

Then we have two separate codecs, one for WMF and one for EMF. Both are decoders only, which means they get used for Image.From[File|Stream] but won't help you to save a metafile, e.g. Image.Save.

Enough text for now...

 
MS System.Drawing/GDI+ versus Mono/Libgdiplus

The Mono's picture was generated using a very limited WMF codec/parser, it doesn't call functions for half of the metafile commands (e.g. in this picture we're visually missing MoveTo and Arc). The next step is to review all existing *Image* code and, in most case, adapted not to use the bitmap data directly (e.g. width). Once this is done, I'll resume work on the WMF parser, then the EMF parser and post pictures from time to time.

P.S. I have not looked much to find free WMF and EMF(+) metafile samples but if you have some free ones (this worked so well for the Vista icons, thanks to everyone :-) I'd like them for the test suite. Right now they don't need to be torture tests ;-). Thanks!


2/20/2007 08:52:50 | Comments | Permalink

Codecs - ICO

I was about to blog about metafiles when I realized I didn't talk, well blog, about icons, so let start with them...

Icon support exists in two ways in System.Drawing and libgdiplus. First there's the Icon class which, for some unknown (to me) reason, doesn't inherit from the Image class. This part existed, up to recently, in a fully managed implementation. However this implementation wasn't able to coexist with native code when using handles e.g. Bitmap.FromHicon(icon.GetHandle);.

The second place where icons could be used, which was totally missing in Mono 1.2.0, is in the ICO codec. This allows the creation of a Bitmap instances from any ICO file. Well almost any ICO as it turns out GDI+ ICO codec is more limited than what GDI (and System.Drawing.Icon) support (e.g. 32bpp icons).

So what's new ? The latest (and greatedt) Mono, version 1.2.3, has full support for both icon cases, including native interoperability. This means that libgdiplus has a (unmanaged) ICO codec and that the System.Drawing.Icon reuse this to provide handle support under Linux (and other platforms using libgdiplus). Under Windows the GDI API is used to support native interoperability.

The only known missing, and untested, icon feature are the new Vista icons. They are larger than before (like the rest of the OS ;-) and use another storage format (compressed PNG from what I've read). Actually I'm not sure how, or even if, they are supported by the existing .NET frameworks... considering that GDI+ doesn't seems to like (and neither does VS.NET 2005 really support) the 32bpp icons introduced in XP. Anyway let me know if you have some totally free Vista icons to add to the test suite. Who knows, we could be the first to support them ;-)


2/12/2007 16:53:45 | Comments | Permalink

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.