flowlabs.net

Psd2Xaml (with a splash of swf)

Simple, free, open-source tool for converting Photoshop .PSD files to XAML. Also supports limited SWF conversion to XAML.
This project is a by-product of the development of PaintLab, a node-based paint application.
Read more about the underlying PSD parser in this article: http://www.codeproject.com/cs/media/PSDParser.asp

Usage

Drag'n'drop PSD or SWF files to the application, and it will create XAML files in the same directory but with the extension xaml instead of psd. The individual layers' bitmaps are saved in a subdirectory with the same name as the output .xaml file plus "_Bitmaps".

Example: "Test.psd" is converted to"Test.xaml" and a new folder with the name "Test.xaml_Bitmaps" will be created, containing the bitmaps.

XAML Output

For PSDs, the generated XAML file has the following structure: (don't know how to make xml appear properly, so I've removed brackets etc)

Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 Canvas
   //For each graphical layer in PSD:
   Rectangle Name="Test_999" Canvas.Left="0" Canvas.Top="0" Width="100" Height="100"
    Rectangle.Fill
     ImageBrush ImageSource="C:\Documents and Settings\Jonas\My Documents\PDN.xaml_Bitmaps\Test.png" Opacity="1"
    /Rectangle.Fill
   /Rectangle
  /Canvas
/Page


SWFs add Paths instead of Rectangles to the file:
  Path Data="M 502,342 L 484,330 C 496.6667,340.6667 503.3333,347.3333 504,350 L 502,342 " Fill="#FFCCCCCC"
  Path Data="M 111,319 L 133,324 " Stroke="#FF000000" StrokeThickness="1"


Known Issues

PSD
WPF currently lacks many compositing features that are necessary to render complex PSD files correctly, so Blend Modes and Adjustment Layers are ignored.
There is some support for the Bitmap Effects that are available in WPF, but the values aren't trimmed to act like Photoshop's effects.

SWF
This converter is very rudimentary. It only handles simple still graphics - no sound, video, code etc. Although the parser handles quite a few features such as animation, morphing, glyph texts, bitmaps etc, I haven't had time to implement the conversion. One major problem that I don't know how to solve is how to render the compound shapes correctly; currently double-sided filling is incorrect.

General
Minor problem: The application is single-threaded so the information textbox doesn't update its contents as it should.

Please report bugs and crashes to the address below.

Downloads

Application: Psd2Xaml.zip (233 kb)
Source: Psd2Xaml_src.zip (226 kb)
Test media: Tiger.swf (16 kb)  DVDMenu.zip (psd, 989 kb)

The application relies heavily on dlls from the Endogine project. Read about it and download its source at http://www.codeproject.com/csharp/endogine.asp
The latest version that implements Xaml export will not be available until sometime by the end of October (they can be slow at updating submissions). Should you need it sooner, e-mail me at the address below.

Contact

Jonas Beckeman
jonas at jobe dot nu