about

Various. This is about, who I am, what I do and things that are relevant to my interests :¬)

following

graphicly dowding robnixon kevinmann sumogray simplegeo
Text

Want the directory of a .Net app?

Then use this line:

AppDomain.CurrentDomain.BaseDirectory

Link

→ likes 28 Weeks Later on Boxee

Link

→ Xml Serialisation (Serialization) in C#

One thing I absolutely hate doing is reading xml, it bores me to bits. So to make this dreadful task a little more easier I use a nice little extension function that I found (and improved; then put up on stackoverflow). If you mark a class with the XmlSerialization attributes (XmlRoot/XmlElement) you can quickly take an xml string and turn it in to an object.

Link

→ ASP.Net Pager Control

I built this quite a while ago - some one might find it useful.

Text

Find the transparent pixels in an image - WPF

The other day I had to create an image element that contained a png with transparent sections and have it display a hand cursor when the mouse was over the opaque sections.

The first thing I tried (and failed) was to have an image element with the cursor property set to “Hand” like so:

<Image Source=”{Binding SomeImage}” Cursor=”Hand” />

That obviously never worked so I was forced to look at each individual pixel and see if it was transparent. What I ended up with was a function that generated a bunch of coordinates.

This is that function:

private static Dictionary<Point, object> FindTransparentPixelCoordinates(BitmapSource source)
{
  var points = new Dictionary<Point, object>();

  // Convert the source if the pixel format is not what we expect
  if (source.Format != PixelFormats.Bgra32)
  {
    source = new FormatConvertedBitmap(source, PixelFormats.Bgra32, null, 0);
  }

  int width = source.PixelWidth;
  int height = source.PixelHeight;
  var bytes = new byte[width * height * 4];

  source.CopyPixels(bytes, width * 4, 0);

  var position = 0;

  for (var y = 0; y < height; y++)
  {
    for (var x = 0; x < width; x++)
    {
      var byteOffset = position;

      // The pixel format is stored as 32-bits (4 bytes) with the last byte being the alpha

      if (bytes[byteOffset + 3] == 0)
      {
        points.Add(new Point(x, y), null);
      }

      position += 4;
    }
  }

  return points;
}
Link

→ The Morning Brew

Fantastic site that keeps me updated on all the goings on around .Net / Development.

Link

→ Chimp TV

The chimps chose a good score to accompany their film ;)

Link

→ WPF 4 & Touch

Invaluable resource for getting start with touch and WPF 4. Helped out greatly when developing the touch features of the graphic.ly WPF app.

Video

Amazing Lego Video - Cheers @kjfletch

Text

Day 0

Until I can think of something to write for this I’ll start off by telling you all little about my self. In bullet form of course ;)

  • Born and bred in the North East of England (Hartlepool to be exact)
  • Software developer for numerous companies (current at Graphic.ly)
  • Former Ice-Cream man
  • Big on Technology / .Net / WPF / C# and other various geek stuff
  • Afraid of heights
  • Love pizza

That’s it for now…

Cheerio

P.S.

I’m also online else where:

Twitter

Facebook

LinkedIn

StackOverFlow

Page 2 of 3