While designing HTML templates, I, like everyone else, frequently use filler text to fill up space before content exists. I’ve been doing this a lot lately in ASP.NET MVC 2. Having static fake Latin filler text in a web application while developing is nice but having random fake Latin text is more useful for a couple of reasons:

It forces your page to render with different lengths of text which can help find bugs

It’s more amusing and beats staring at the exact same text

Since I’m working in ASP.NET MVC mostly, I’ve used C# to create several extension methods on the HtmlHelper object. This enables me to generate fake Latin text inline in HTML and Views.

I’ve been working on a little project that requires Microsoft SQL CE databases and couldn’t find anything that did quite what I wanted. SQL Server Management Studio allows for design of CE databases but not for browsing/editing data easily.

I’ve gone on a strange image manipulation kick in c# recently. Partly because I needed blurring method for something (then pixelation spawned from that) and then partially because it was fun. Here’s how to remove color from an image in c#:

*Update: I was poking around on the Internet, looking at things and stuff and found a better greyscale implementation (read: faster, much faster and a bit more complex) from Switch On The Code. Check it out:

The pixelate method looks at ever block of pixels in the pixelate size, grabs the middle pixel and then sets all of the pixels in the block to that same color. If you don’t use the middle pixel, the image ends up shifting (my initial version looked at the top-left pixel.)

Dad at Christmas

Pixelated Dad at Christmas

If you want to pixelate the whole image, just use the bounds of the original image as the pixelate rectangle. Here’s an example of how to overload the Pixelate() method:

Blurring an image with c# is pretty simple. I was messing around with something one night and needed to blur certain regions of JPGs that I was processing. This method accepts an image, a blur region (rectangle), a blur size and returns a blurred bitmap.

The method takes a look at every pixel within the blur rectangle and samples the reds, greens and blues within the blur size to figure out an average. Then it sets every pixel within the blur size square to the average color.

Jellyfish at the Monterey Aquarium

Blurred jellyfish at the Monterey Aquarium

If you want to blur the whole image, just use the bounds of the original image as the blur rectangle. Here’s an example of how to overload the Blur() method: