Thanks to GreatLord for spotting that we shouldn't access pixels outside the