One final nitpick - it's safe to pass NULL to the color component retrieval methods. Since we're not using the alpha value, let's just get rid of that variable and pass NULL.