Save UTexture2D as 8-bit or 16-bit PNG C++

I aim to create a Heightmap generated via C++ and then used for the landscape!
I managed to generate the UTexture2D and Save it as PNG but I get this when trying to import the png file to the landscape:
image

When I tried to figure out what was wrong I found that the png file was saved either as 32bit using

FImageUtils::PNGCompressImageArray(Width, Height, Colors, ImgData);

or 24bit using

FImageUtils::ThumbnailCompressImageArray(Width, Height, Colors, ImgData);

Does anyone have any idea how to save it as 16-bit or 8-bit png? I searched everywhere and I couldn’t find any solution!

Thank you for your help!

you can try IImageWrapper::SetRaw with InFormat= Gray

I tried so many settings and methods and the best result is a blown-out image with somehow a different pattern than the original texture!
Original Texture
image