C++ 16 bit grayscale gradient image from 2D array?

I'm currently trying to build a 16 bit grayscale "gradient" image but my output looks weird so I'm clearly not under...