Monday, April 20, 2009

Converting Campaign Cartographer Files to XAML

ProFantasy created a program named Campaign Cartographer. The program allows the quick creation of very high quality maps for role playing type of games. I was working on a logo for the company I am trying to start. I wanted to create a Silverlight XAML file for the logo. I knew that Campaign Cartographer could quickly and easily create a piece of the Logo. Now for the challenges in getting that file into XAML. Campaign Cartographer has only a limited number of vector output options. I could easily create a bitmapped graphic in a variety of formats, but I wanted to stay in the vector space. The logical place to start is as a Windows Metafile (.wmf or .emf). I exported the metafile and tried using one of the freeway tools EMFtoXAML. This produces basically produces an empty file. EMFtoXAML does not support any of the drawing commands used by Campaign Cartographer. I then tried reading the .emf file into Adobe Illustrator CS 1 (the most recent version I own). The result is very low quality. My next step was Corel Draw 12 (the most recent version I own). Again, the result was awful. I gave up on .emf files. Now to try another vector format: AutoCad .dxf. Now the fun begins. The current release of Campaign Cartographer is version 3. On my system, Campaign Cartographer 3 crashes when trying to export a .dxf. I then fire up an old PC that has Campaign Cartographer version 2 installed. This program exported the DXF without problem. Then went back to Adobe Illustrator CS 1 to try and import the .dxf file. Again, Adobe Illustrator did not render the import usable. My next step was back to Corel Draw 12. Corel Draw 12 imports the .dxf. The result of the import into Corel Draw is not perfect. The import removes most but not all of the color. At least the outline is clean. Corel Draw can export an Adobe Illustrator file or .ai file. I installed the preview version of Expression Blend 3.0 from Microsoft. Expression Blend 3.0 is supposed to be able to import Adobe Illustrator files and create XAML. I fired up Expression Blend and created a Silverlight project. Expression Blend disables the menu options to import an Adobe Illustrator file when you create a Silverlight project. After fumbling around for a while I tried creating a WPF project in Expression Blend. That allows importing Adobe Illustrator files. I did some searching on the web, and nothing mentions you can only import Adobe Illustrator into WPF projects. I tried importing the Adobe Illustrator file created by Corel Draw 12. Expression Blend 3.0 Preview says it cannot understand the file and cannot import it. I then go back to Adobe Illustrator. I open up the file created by Corel Draw in Adobe Illustrator and save the file back as another .ai file. It is interesting to note the Adobe Illustrator's default name for the file adds the word "[Converted]" to the file name. I open Expression Blend 3.0 back up to my WPF project. Finally I can import the .ai file and the image appears in Expression Blend. The colors are gone, but at least I have the XAML file I can work with. I hope that someday ProFantasy will add the ability to export data directly into XAML.

1 comment:

Lee Saunders said...

The issue with EMFs in CC2/3 is the original parameters in CC2/3. I think its 2" x 3". Way too small for quality. If you bump it WAY, Way up you run out of memory, but you can increase it quite a bit and get a great result. Then to get it into XAML, use the "Print it to XPS then pull out the XAML" trick. You can either google it or go to my blog (oldschooldotnet.blogspot.com) to learn this trick.