Funny you mention this,.. I'm currently teasing my brains with a 2D pixelperfect collision detection routine (in opengl), for about an entire day now. It's harder than I thought.

Anyway, perhaps lesson 30 on nehe's site, might be useful to you.