Function to get the value of a pixel on a surface.