Is there an obvious better way of handling window borders?
I would restrict the window-size to be multiples of the GIFs size (32x8) - seems the easiest way :-) That way you don't have to stretch or go the extra mile to draw the first y pixels of the last partly seen segment.