-2

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.

milbrandt
  • 1,438
  • 2
  • 15
  • 20
Balan Narcis
  • 139
  • 1
  • 10

1 Answers1

1

you need to loop through your array and convert each int16 to RGB value. If terrainis 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

milbrandt
  • 1,438
  • 2
  • 15
  • 20