I’ve done a lot of experimenting to generate XAML with my vector drawing tools, and Office apps. I learned if you copy vectors from Illustrator and paste them into PowerPoint, they are rasterized into a .png. If you copy and paste those vectors into Visio they remain vectors… or so I thought. I couldn’t figure out why sometimes my process generated rasterized bits and pieces of my file, and other times it didn’t. The problem seemed to be the gradients.
Here’s an example: I have exported an svg file from Illustrator via the Windows Client Print Driver to XAML. I expected to preserve the vectors and generate a single XAML file. What I got was a XAML file and a folder with 189 .jpg files and 1 .png. It was as if my file had been rasterized, sliced, and diced.
Wei Zhu had an answer for me:
The WCPD does handle GDI’s GridentFill calls. The problem is that no application (that I am aware of) seems to use GDI’s GradientFill API. I think it’s most likely due to the fact that GradienFill in GDI is only available on Windows 2000 and up and applications seemly choose to simulate gradient fills with bitmap strips.
Not every app simulate gradient fill the same way either. The Illustrator app seems generate a lot of bitmap strips. Office 2003 does a smarter job and simulates a gradient fill with just a single 1 pixel high image strip. If you try the attached power point file, you can see the result xaml to be like this.
<FixedPage Width="11in" Height="8.5in" Background="White" xmlns="http://schemas.microsoft.com/2003/xaml">
<Path Data="M 48 48 L 1008 48 1008 768 48 768 z" FillRule="NonZero" Fill="#ffffffff" />
<Image FixedPage.Left="231.84" FixedPage.Top="263.84" Width="392.32" Height="208.32" Stretch="Fill" Source="image_1.JPG" Clip="M 0.16 0.16 L 0.16 208.16 392.16 208.16 392.16 0.16 z" />
<Path Data="M 232 264 L 232 472 624 472 624 264 z" FillRule="NonZero" Stroke="#ff000000" StrokeThickness="1.04" StrokeLineJoin="Miter" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeMiterLimit="8" Clip="M 0 0 L 0 816 1056 816 1056 0 z" />
</FixedPage>
Where image_1.jpg is a 2KB 1x2604 dimension file.
Turns out when I’m pasting vectors into Visio it’s preserving what it can, and rasterizing the little bits and pieces it can’t (gradients). Who knew? Mr. Zhu knew, did you?