stroke my ego
Knew Steph wouldn't be home late until tonight, and chances to do this on a whim are going to run out, so I decided to wander around the UWA campus after work with a tripod and my camera. Most of the photos I took were lemons, but there were a couple that came good. My fragile ego wants to know what people think. Constructive criticism also gratefully accepted.

the back of Winthrop Hall

and the front, overlooking the reflection pondMy 40 ringgit tripod behaves pretty much how you'd expect: poorly. It's very, very shaky. Many of the photos took several attempts. Some that I thought would work really well, like the library, didn't turn out at all. I hadn't originally intended to walk up to the reflection pond, but sat on the pavement I think I got some really nice shots.

reflection pond

clocktowerOn the technical front; I upgraded my laptop to the new Ubuntu today using their upgrade app and everything. Things actually went perfectly. Upon rebooting and seeing X start I thought about how far we've come (and how I still have such low expectations). Everything seems much less broken than the betas I tried when writing the GNOME release notes. Ubuntu's non-free driver applet seems to need 10MB of writable memory for something though... that seems strange.
Finally, football at night makes for interesting photography. I got quite a few good shots, but I think this was my favourite:

some people move more than others
(
posted on Wednesday May 7th, 2008 at 10:38 pm — 7 comments)
more on masking
Yesterday I talked about creating a mask to speed up your drawing with Cairo. I mentioned that I had a bug where, unlike my test case, my real code was running slower rather than faster. As I suspected, this is because my operations weren't pixel aligned (I had floor(x), not x = floor(x), whoops!). Fixing this bug gave me my 10x speedup that I'd measured in my test case, but revealed the other edge of the sword, all of my markers were now pixel aligned.

The solution I came up with was to create a series of subpixel aligned masks that would give the same effect as the old antialiasing code.
First up is to create the masks:
int i;
for (i = 0; i < NSUBPX; i++)
{
int j;
for (j = 0; j < NSUBPX; j++)
{
cairo_t *cr2;
mask[i][j] = cairo_surface_create_similar (
cairo_get_target (cr),
CAIRO_CONTENT_ALPHA, 16, 16);
cairo_surface_set_device_offset (mask[i][j], 8, 8);
cr2 = cairo_create (mask[i][j]);
/* add a certain amount of subpixel offset for this mask */
cairo_translate (cr2, 1. / NSUBPX * i, 1. / NSUBPX * j);
draw_func (cr2) /* draw onto the mask */;
cairo_destroy (cr2);
}
}Now we need to remove the transformation matrix from our target surface so that our compositing operations are fast:
cairo_get_matrix (cr, &matrix);
cairo_save (cr);
cairo_identity_matrix (cr);
Now for each point, we can work out it's location on the canvas, choose a mask to use and a pixel to align to:
/* transform the point from plot space to device space */
x = point->x; y = point->y;
cairo_matrix_transform_point (&matrix, &x, &y);
/* choose an appropriate subpixel mask */
xi = CLAMP (((int) (x * NSUBPX + 0.5)) % NSUBPX, 0, NSUBPX - 1);
yi = CLAMP (((int) (y * NSUBPX + 0.5)) % NSUBPX, 0, NSUBPX - 1);
x = ((int) (x * NSUBPX + 0.5)) / NSUBPX;
y = ((int) (y * NSUBPX + 0.5)) / NSUBPX;
cairo_mask_surface (cr, mask[xi][yi], x, y);
Don't forget to destroy your mask surfaces when you're done or you'll find yourself leaking video card memory.
I've currently put NSUBPX at 3 for this result:

(
posted on Tuesday May 6th, 2008 at 01:36 pm)
drawing faster with Cairo by using masks
N.B. this little trick isn't for everyone, but for some things it can really speed up your plotting code.
I am writing a widget to draw scattergrams. Each point on the scattergram is a little tiny circle and I have to draw thousands of them. Using straight X11 and drawing each arc individually is actually really quick, but a naïve port to Cairo, where each circle is individually stroked is really slow. Reaaaally slow.
Enter masking. In Cairo's language a mask is something you apply a source to to draw on a surface. In effect, you can think of the mask as a stencil (or masking tape); that you spray paint in your source colour over; to produce an image on your drawing surface. Your mask is an 8-bit alpha channel, the more opaque each pixel the more colour gets through to the target surface.
To create a mask, you want to use the same type of surface as your target surface (e.g. an XlibSurface). Use cairo_surface_create(). The content is ALPHA. You can then draw in your mask like a regular surface. To paint your mask onto the target surface use cairo_mask_surface(), the source colour/pattern defines what colour/pattern will be applied through your mask onto the target surface.
For example here is a naïve example repeatedly using cairo_arc() and cairo_stroke():
static void
expose_da1 (GdkWindow *window)
{
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE (window));
double x, y;
cairo_set_line_width (cr, 1.0);
for (x = 0; x < SIZE; x += INC)
{
for (y = 0; y < SIZE; y += INC)
{
cairo_arc (cr, x+DIAM/2., y+DIAM/2., (DIAM-1)/2., -M_PI, M_PI);
cairo_stroke (cr);
}
}
cairo_destroy (cr);
}Here is the same image but using a mask that we prepare in advance:
static void
expose_da3 (GdkWindow *window)
{
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE (window));
double x, y;
/* create the masking surface */
cairo_surface_t *circ = cairo_surface_create_similar (
cairo_get_target (cr), CAIRO_CONTENT_ALPHA,
DIAM, DIAM);
cairo_t *cr2 = cairo_create (circ);
cairo_set_line_width (cr2, 1.0);
cairo_arc (cr2, DIAM/2., DIAM/2., (DIAM-1)/2., -M_PI, M_PI);
cairo_stroke (cr2);
cairo_destroy (cr2);
for (x = 0; x < SIZE; x += INC)
{
for (y = 0; y < SIZE; y += INC)
{
cairo_mask_surface (cr, circ, x, y);
}
}
cairo_destroy (cr);
cairo_surface_destroy (circ);
}(
Complete example source)
So how much faster does it get? Well, the exact answer depends on your graphics hardware and video driver, but on my laptop, the Cairo implementation went from taking 0.72s to 0.08s. The straight X11 implementation takes 0.007s, but of course is not antialiased.
Masking works best at integer offsets and 1:1 scaling, it may actually be slower than individual stroking if you don't have these.
As for my widget? Well, that's a funny story, after sorting out this test case I ported the code into my widget and for my troubles received a factor of 2 slowdown! (but I've got a theory about what's causing this which I'll test out tomorrow).
(Big thanks to behdad and #cairo for help with my test cases today).
(
posted on Monday May 5th, 2008 at 10:09 pm — 1 comment)
choose your friends to fit your beliefs; not your beliefs to fit your friends
This post about my life is accompanied by pictures of seagulls and boats. There is no reason for this, I just want to seem artsy.
As previously mentioned, we're currently in the process of finding somewhere new to live. After this weekend we've looked at nine properties for sale around Highgate and Mt Lawley. At least one of them seems like a place we could offer on. A number of them have potential, but you'd need to completely rennovate them first, we really don't have time. We're going to look at some more next weekend.
The idea of buying is a little daunting. It's affordable (as long as we're both employed), but it's certainly a lot of liability. I suppose it doesn't really reduce our flexibility any more than a fixed-term lease, we could always sell or rent the place out if our futures take us away from Perth (indeed Tom and Max did this). It seems like such an adult thing though, owning property, like being married.

Knowing that we have to leave has left me in a bit of a funk. This flat has really become our home in the last three and a half years. And it sounds silly, but there are things in the neighbourhood that we'll miss: like crazy postoffice guy and the kebab shop. For somewhere around a quarter of my life I've lived within 200m of the same supermarket (it's had 2 name changes and renovations during that time).
But there are some things to feel excited about, like being able to hang up all of the art that we've got tucked away (and indeed purchase additional, awesome art because we know we'll have somewhere to hang it) and possibly obtaining a balcony or courtyard. I think my problem is that where we live no longer feels like
our space and that house hunting cannot be turned into a 24x7 exercise, so maybe things will seem happier once we have somewhere new.

It's possibly related, but I've been feeling very bored lately. I have zero motivation to work on anything that involves computers or programming (feels too much like work). Actually, I'm feeling demotivated in general. I guess this is why people just come home and watch TV all night. I currently have no academic pursuits; I thought about picking one up, but I'm actually enjoying not having the stress. I think I just need to rediscover hobbies that don't require daylight or a partner (when Steph is studying). Friends always seem to be busy.
I finally got around to replacing the audio cables in the
fit-PC I bought a while back, meaning that the sound now works. I originally bought this thinking it had a PC-card socket inside (it does not), and was going to turn it into a wireless AP/media box, but we'll probably get ADSL2 when we move which means we'll need a new modem anyway (so we'll probably get some integrated do-whatsit) and the thing has some pretty serious sound/video sync issues with multimedia. Thus I'm not actually sure what to do with it.

Renovations for our half the floor at work start tomorrow, so Programming has been temporarily moved downstairs. Going open-plan again hasn't actually been too bad. The renovation is taking 8 weeks, so I'm not sure whether or not to actually unpack my box of stuff from upstairs. I did sit my penguins on a shelf and put up my poster of Richard Feynman though.
I've also heard that Cowie and I are speaking at GUADEC. Both Matt and I are meant to be going from FSI this year. Should be fun times. I just have to hope that house-related stuff doesn't throw a spanner in the works (especially after missing last year).

Umm, what else. I went to
IEAust to receive my certificate for joining since it's literally around the corner from work. I've also joined IEEE (although this seems to mostly be a way to sign up for conference spam). I wasted a large amount of time rewatching the Hornblower mini-series because boats are cool and people acting affronted are funny. Steph and I also finished watching Carnivale. The beginning was very shaky. It seemed like each writer was pushing his/her OTP during their episode, but it was actually quite awesome once it got going. Of course now I can't help but think that the Methodist church is creepy and sinister. Clearly they were expecting to be allowed to make more chapters in the future, because it leaves you hanging. Speaking of such things, we still haven't finished chapter 2 of Heroes.
Oh, and apparently it's ok for a politician to sexually harass one of their staff, "because there are worse people in Parliament". I like this reasoning, it's like a get out of jail free card (literally) for a whole bunch of crimes I might like to commit one day, because at least they're not as bad as beating someone half to death with an iron bar.

(
posted on Sunday May 4th, 2008 at 10:54 pm — 13 comments)
English language to appear in court to face charges of alleged Grand Larceny
Since it seems that no one has mentioned this...
Lesbos islanders dispute gay name (BBC)
Sure 15 year olds may laugh when they read Isle of Lesbos, but surely this is going too far. What's next, someone banning the word homogeneous?
Seriously...
(posted on Friday May 2nd, 2008 at 07:05 pm — 13 comments)
back on the market
We received a letter today informing us that the lease for our flat will be terminated in 60 days. While I can appreciate that the university wants to replace people with jobs for poor students and underpaid academics in its housing; I hope that the same thing hasn't affected any recent graduates who don't yet have a real job.
Regardless of this, we now get to surf the real estate market for the first time in ages. This was probably going to happen soon enough any way, I just wish it was on our terms rather than someone else's. We're not particularly attached to living in the western suburbs triangle. We're currently thinking of trying the pink triangle instead.
The idea of buying instead of renting has appeal. It'll all depend on several factors: like what direction we're thinking of taking in the next couple of years. On the other hand, if you have property close to the Perth CBD that you're trying to sell/rent, let us know!
(posted on Monday April 28th, 2008 at 10:12 pm — 8 comments)
thoughts on Apple Aperture
Some time ago, Apple released a photo management app called Aperture. The consensus was that it didn't make the grade. Later they released a new version, which was recommended to me at a wedding a few weeks back (not my own). It had some interesting sounding features, so I decided to find out what it was like by trying the demo.

arrow in flightFirst up, it doesn't currently support the Canon EOS 450D's RAW format. The files will import (the import UI is excellent), but Aperture will be unable to view them. For the time being you have to use Adobe's DNG converter (which does support the camera). If you export the .CR2 files from Aperture, Adobe's converter won't be able to read them. I had to copy the files onto the computer using the EOS Utility from Canon (which is fairly awful), convert them and then import the DNGs into Aperture. Apple link to the Adobe DNG converter as a way to support cameras not natively supported in Aperture. It would be nice if Aperture could just pump the files through the DNG converter automatically if required/requested.
The photo viewing UI seems pretty nice. It has the typical Apple animation spam but is reasonably snappy. Sometimes however it's hard to tell what display mode you're in. The neatest feature, one that should appear in more applications is the idea of a
stack. You can collect a whole pile of photos of the same subject into a single stack, which can then be collapsed to one image on the filmstrip. You can then compare the currently chosen best image against all the other images in the stack and choose a new best image.
Apple advertise a rich selection of keyboard shortcuts so that you needn't take your hands of the keyboard, but to me these seem to suffer from typical Apple keyboard-shortcut brain-damage. I think there is a UI to edit them, but I didn't check.
Aperture offers a number of image adjustment and editing tools. While the algorithms employed here don't seem any more advanced than those in the Gimp, the UI seems to be reasonably well thought out. It allowed me, who knows relatively little about image processing to adjust the sliders and come up with a nice image. There are little checkboxes to indicate whether or not to apply the effect, which allows you to gauge the effect. Something simple that really impressed me was being able to show the sensor hot/cold spots as an overlay so that you could compensate for sensor burnout/blackout. Image adjustments are applied non-destructively.
By default, Aperture wants to store your photos in its Aperture Library, which you can put anywhere you like on the system. The library is some sort of opaque storage, I've not had a look to see if it uses a technology that you could recover your files from. You can however store photos anywhere you like and just reference them in the Aperture Library, which would guarantee that you can always access your photos later.
Aperture can export your photos (either masters or versions) as RAW originals or JPEGs (possibly other things too) to your computer. Apple also advertise direct export to Flickr. It turns out however that this is implemented as a 3rd party plugin and costs you extra (I don't really mind this, I just wish Apple were more upfront about it).
My first impression: it seems reasonably neat and worth further experimentation. It's probably not for managing the random photos you take from day to day, but seems well suited to dealing with the photos from a specific project. It's probably worth $270, assuming that it's supported for more than 20 minutes (although, this is Apple), it's cheaper than
Adobe Lightroom (which I've not yet tried). I wish it could natively handle my camera, but I assume this will come in time. It has some really swish features that I would love to see appear in F-spot.
(
rest of photo set)
(
posted on Sunday April 27th, 2008 at 05:18 pm — 15 comments)
reflection on the supreme sacrifice
Today is a day to take a moment to reflect on the futility and waste of war. Let us wish for a day where one person does not raise arms in aggression against another for any reason. Let us remember those who's lives have been lost; and send a message to our leaders not to make the mistakes of the past in our future.

lest we forget(Photo CC-BY-NC-SA
larinalou)
(
posted on Friday April 25th, 2008 at 10:20 am — 4 comments)
"The vicar? Why would you encounter the vicar?" I asked incredulously.
I tried an experiment when photographing my degrees using a $10 umbrella that has a reflective silver inner and my flash gun pointing into it over my shoulder. Stephanie found this most amusing.

It actually seems to work pretty well. I snapped this shot of Stephanie holding the umbrella in my left hand with the flashgun pointing backwards into the middle.

Since Steph has a Flickr pro account, I have started experimenting with using it for uploading the random photos that I take (rather than just dumping them in an images directory).
(
posted on Tuesday April 22nd, 2008 at 11:00 pm — 1 comment)
"I can't go out like this!" she bemoaned. "Someone might see me! What if I should meet the vicar?"
Two items of registered mail arrived for me that I picked up this morning on my way to work.

So that's the complete end of it. I applied to join Engineers Australia and IEEE today.
Although Stephanie beat me to it, and has already uploaded her favourite photos to flickr, I have been steadily uploading photos from the wedding and honeymoon. Thus:
More holiday snaps to come in the near future.
(
posted on Tuesday April 22nd, 2008 at 10:48 pm — 1 comment)
jpegexiforient broken?
For quite a while, when uploading to Original, I've run the photos through exifautotran, a shell script that uses jpegexiforient to read the EXIF Orientation flag and rotate each image for the web. Since getting the 450D I'd noticed that exifautotran was no longer doing anything, which I tracked down to jpegexiforient returning no orientation (nor being able to set the orientation either). I thought this was weird because GNOME (eog, f-spot, nautilus, gthumb) and MacOSX (Finder, Preview) both displayed the photo correctly.
Today I had a look at the source code to jpegexiforient and I found that it was silently returning because the first byte of the file was not FF, D8, FF, E1. Using my trusty hex editor I discovered that my file starts FF, D8, FF, E0. FF, D8 indicates the beginning of a JPEG file and from the EXIF spec, it can be seen that FF, E0 is the beginning of a JFIF block. In my file FF, E1, the beginning of the EXIF block, doesn't appear until after this. So while there is nothing wrong with my file as far as I can tell, jpegexiforient won't accept it.
My solution? I'm now using the program jhead to batch-rotate images, which seems to work correctly and also provides a number of other useful features.
It's worth noting that Windows Media Centre also didn't like the orientation flag. Neither did whatever version of Elisa I'm currently running (which is not the latest).
(posted on Tuesday April 22nd, 2008 at 12:00 am — 1 comment)
I think I went a little overboard on the unsharp mask
From Saturday fortnight back...

taken by the tallest Amanda ever (bigger)
(
posted on Friday April 18th, 2008 at 12:38 am — 4 comments)
this is no polar expedition
Having looked at the travel journal of some friends who left for their trip on the same night as us, their photos seem both more interesting and of higher quality and they're actually managing to update frequently. On top of this the prose is excellent and insightful.
So in an attempt to make amends, here are some more photos from our trip...

view of Penang, towards the south-east, from Penang Hill
 |  |
| Pagoda at Kek Lok Si | the most beautiful of my wives |

Boeing 777 (included for the enjoyment of Capt. and Ltnt. Excitement)

Clarke Quay at on Friday night

Suntec City and the Singapore Flyer

Sentosa MerlionI need to think about how to upload all of our photos... I took about 4GB worth... perhaps I'll simply ditch the full-quality versions. I'm also going to need a bigger hard drive.
(
posted on Wednesday April 16th, 2008 at 11:28 pm — 22 comments)
as of today this is the longest I've ever been married
Steph and I are in Changi airport waiting for our flight home (so I'm taking advantage of their free wireless). Just posting some teaser shots from the tallest Ferris wheel in the world.

financial district

Benjamin Sheares BridgeIt seems that all the best photos I took of the city have been at night. Any cityscape taken at day has been hazed out in whatever the haze is that seems to perpetually engulf Singapore. This is probably the best one I have, it's still very hazy. Notice the Singapore Cricket Club in the midground.

city by day
(
posted on Tuesday April 15th, 2008 at 05:27 pm — 9 comments)
symphony in the bathroom
This is just a quick post to say that Stephanie and I are still alive, we're having fun and everything is going swimmingly.

Singapore - view from our balcony - is this building meant to look like a durian?Got to Penang with no dramas. The hotel was about 30 minutes drive from Georgetown (even though it's a tiny island). Most drivers aren't nearly as bad as they are made out to be, they're just lazy. It seems however that that road rules do not apply to taxi drivers.
Meeting Stephanie's extended family turned out to be ok. We had a full wedding banquet (the second one) with what was possibly the most delicious vegetarian food I've ever eaten. Steph and I visited
Kek Lok Si temple (which, as with all beautiful buildings I go to visit, was covered in scaffolding), Penang Hill and the reclining Buddha (referred to by my new uncle-in-law as "the best buddha in town").
Arrived in Singapore on Thursday night to discover that our hotel was unexpectedly posh. I'm actually feeling quite underdressed when we go down to breakfast. The curtains are opened and closed by control panel next to the bed. Singapore has much impressive technical integration... a unified system for billing toll roads and parking using a device in your car... brilliant.
So far we've visited Little India, the Asian Civilisation Museum, Merlion Park, Clarkson Quay (briefly), Orchard Road (some of it) and Jurong Bird Park, where we got trapped for an hour under a shelter while rain bucketed down. The smallness of some of the enclosures made me sad.

king penguins at Jurong bird parkWe've eaten lots of delicious vegetarian food. Stephanie has lots more on her list to try. We've taken a stack of photos (I'm going to need a bigger HDD).
If you're looking for wedding photos
Steph has linked to some. We'll probably be offline again until we get back home on Wednesday.
(
posted on Saturday April 12th, 2008 at 11:10 pm — 11 comments)
(Untitled)

photo by AmandaOur friends and family are very generous givers... wow. Thanks again, guys.
Thanks also to all the well-wishers who've
left their comments.
(
posted on Sunday April 6th, 2008 at 10:08 am — 2 comments)
status: married
Today was really awesome. The weather cleared up in time and things went off without a hitch (the advantage of playing it by ear). Of the whole evening, what I found the most touching was how everyone comes together not only to have a good time, but to really help out when help is required (I love you all).
We're off tomorrow night for 1.5 weeks.
(posted on Sunday April 6th, 2008 at 02:17 am — 23 comments)
GTK+ theme colours followup
Following up from my recent post on the topic of accessing GTK+ theme colours. The reason it didn't work was actually quite simple (although I didn't find it documented anywhere). Colours from the theme are not set in a GtkStyle until that widget is realized, during a widget's initialization (or even when ::parent-set is triggered) a widget may not be realized. The correct thing to do is to get the colour when ::realize is triggered. Before ::realize happens, you will get the GTK+ default colours, not the theme colours you were really after.
P.S. It appears that someone was not a fan of my last blog post and is apparently of the opinion that I can't use my blog as a mass communication medium to a group of people that they're not a part of. To this person I say: I will write what I damn well please in my blog. Not every aspect of my life revolves around a computer or the programming thereof, and thus if I want to write about music, politics, the sexuality of penguins in New York, my life, radioactive metals I have previously misplaced or weddings, I will. If you don't want to read it here is a solution.
(posted on Wednesday April 2nd, 2008 at 08:54 pm — 2 comments)
there has been some angst regarding dress codes
For those angsting about Saturday and what Steph has dictated you can and cannot wear, maybe this will clear some things up.
Black pants/jacket (e.g. a suit) are perfectly fine. But don't wear all black (e.g. suit and shirt), it's bad form (plus you'll look like a member of the wait staff).
White is right out. It's bad luck.
Red is out too. Stephanie will be wearing red, so you should not.
I apologise if this seriously reduces your wardrobe choices, but perhaps you can think of any required expansions as a positive contribution.
Hats and hairpieces are actively encouraged. Not enough people wear hats to weddings in Australia.
2 days, 20 hours, 43 minutes.
(posted on Wednesday April 2nd, 2008 at 06:17 pm — 20 comments)
happy doubleness

today

the futureAll PhotosAlso
photos from Tommo's bucks night.
(
posted on Sunday March 30th, 2008 at 12:08 pm — 4 comments)
Back 20