It can encode the difference to the previous pixel either up or above (or some combination). In purely horizontal or vertical gradients that's just as efficient as encoding constant color (and in fact, the Wikipedia page shows an example). For gradients in other directions, it depends on how homogeneous the slope is (because it will zip the diff to the previous pixel, i.e. the slope).