C++ 如何将hight(int16)值返回到rgb表单?

C++ 如何将hight(int16)值返回到rgb表单?,c++,c++11,directx-11,heightmap,C++,C++11,Directx 11,Heightmap,我有一个int16*heights[width*height]数组,它保存地形高度,我直接将它们作为int16*加载到一个文件中 我需要将高度写入bmp文件 考虑到int16最初是以bmp文件(rgb格式)的形式出现的,如何将其恢复为rgb格式 谢谢。您需要在数组中循环并将每个int16转换为RGB值。如果地形是您的阵列 for (auto i=0; i<width * height; i++) { auto Color = terrain[i]; auto red = G

我有一个int16*heights[width*height]数组,它保存地形高度,我直接将它们作为int16*加载到一个文件中

我需要将高度写入bmp文件

考虑到int16最初是以bmp文件(rgb格式)的形式出现的,如何将其恢复为rgb格式


谢谢。

您需要在数组中循环并将每个int16转换为RGB值。如果
地形
是您的阵列

for (auto i=0; i<width * height; i++)
{
    auto Color = terrain[i];
    auto red = GetRValue16(color);
    auto green = GetGValue16(color);
    auto blue = GetBValue16(color);
}
用于(自动i=0;i