• Image editing

    Tags: wpf

    I had an idea of how I wanted the title images to look on this site, but it has been hard to find something to make that a reality.

    First I tried Inkscape, which is pretty decent although the UI could use a lot of polish. Unfortunately the capabilities of Inkscape are mapped from SVG - which doesn't have multiple pages - so I couldn't put everything together in one file.

    Then I realised I might need to move more towards a design tool rather than art tool, so I tried Microsoft Publisher (I own it so why not?). While you can have multiple pages (duh), you can't have them different sizes. And to add to that the page guides sit under everything, which is useless when you have an image as the background.

    Then I tried Scribus but quickly uninstalled it.

    So, I decided to use something that I know: WPF! I whipped up some UserControls for each image, and created styles to set up the font and colours the way I wanted it.

    I then wrote a little code to save each rendered control to an image:

    void RenderControl(FrameworkElement element, string fileName)
        RenderTargetBitmap bmp = new RenderTargetBitmap((int)element.Width, (int)element.Height, 96, 96, PixelFormats.Pbgra32);
        PngBitmapEncoder encoder = new PngBitmapEncoder();
        using (var fileStream = new FileStream(fileName, FileMode.Create))

    And then call it with each control and a filename. This worked correctly for the first image only, which was a bit puzzling, but after a search I discovered that the control is rendered in its local space; if it has a margin then the control will be offset and wont match up with the rendered bitmap! Putting each control in an empty border resets their positions and now they all render correctly. Works great!

  • Beginning anew

    I've started a new site here and am trying out Orchard. It seems to be a very well designed from what I've seen so far and is nice to use. I first installed BlogEngine but that felt clunky and limited. Orchard is very modular so if there is something I want to do I can probably code it up fairly easily.

    I managed to waste a lot of time trying to get it to build from tfs/git and deploy to Azure, just building it manually and publishing works though. As I doubt I will be updating it very often this is acceptable. I did read something about deploying it as a web role which would probably work better but I'm not going to waste any more time when it's working!

Symbol Explorer is a free application that allows you to peer into those pesky .lib files to see what's in there.


View Simon Stevenson's profile on LinkedIn