On PIL and aggdraw

This isn't in "Developer Stuff" because it isn't related to Django and I don't want to pollute the Django Community Aggregator.

Along with my addition of the "public" field last night, I also refactored my clock rendering code to use the aggdraw library because it's compatible with PIL and it renders nice, anti-aliased lines.

The refactoring wasn't completely trivial, but it wasn't so bad, but I ran into a whole other mess when I tried compiling aggdraw on my slice.

It compiled fine on the Ubuntu VPS I had running inside VMWare Fusion, but on the slice gcc threw an error because the code was attempting to cast the data in a way that would "lose precision".

I beat my head against this for about an hour before I noticed that when I was compiling for the slice the target was for x86-64. I search for 64-bit related errors in aggdraw and I found a post. Subhash Chandra's fix did the trick. I'm posting his diff below, because Subhash's blog doesn't give him nifty coloured code outputting.

Index: agg2/include/agg_array.h
--- agg2/include/agg_array.h (revision 521)
+++ agg2/include/agg_array.h (working copy)
@@ -520,7 +520,7 @@
int8u* ptr = m_buf_ptr;
if(alignment > 1)
- unsigned align = (alignment - unsigned(ptr) % alignment) % alignment;
+ unsigned align = (alignment - (unsigned long)(ptr) % alignment) % alignment;
size += align;
ptr += align;
if(size <= m_rest)

And of course, quoth the author: YMMV.