I have int16 * heights[width * height] array, that hold the terrain height, i load them form a file directly as int16 *.
I need to write the heights into a bmp file.
How do i get int16 back into rgb format considering they came form a bmp file (rgb format) in the first place?
Thanks.
you need to loop through your array and convert each int16 to RGB value. If terrain
is your array
for (auto i=0; i<width * height; i++)
{
auto Color = terrain[i];
auto red = GetRValue16(color);
auto green = GetGValue16(color);
auto blue = GetBValue16(color);
}
Critical point is your definition of the three functions GetXValue16
as RGB is usually in 4-byte representation of integer, ie int32. See also Extracting rgb color components from integer value