From 754a14533fcc28e3c9cc2f05f269eb0922f8e35d Mon Sep 17 00:00:00 2001 From: avolkov Date: Fri, 16 Dec 2005 06:47:53 +0000 Subject: [PATCH] Finalizing support for externally supplied elevation data (grayscale images) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2079 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/planets/plangen.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index dca0bd0c0..81d013521 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -1725,6 +1725,9 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, FRAME SurfDefFrame) if (GetFrameCount (SurfDefFrame) > 1) { // 2nd frame is elevation data + int i; + BYTE* elev; + ElevFrame = SetAbsFrameIndex (SurfDefFrame, 1); if (GetFrameWidth (ElevFrame) != MAP_WIDTH || GetFrameHeight (ElevFrame) != MAP_HEIGHT) @@ -1736,6 +1739,13 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, FRAME SurfDefFrame) // grab the elevation data in 1 byte per pixel format getpixelarray (Orbit->lpTopoData, 1, ElevFrame, MAP_WIDTH, MAP_HEIGHT); + // the supplied data is in unsigned format, must convert + for (i = 0, elev = Orbit->lpTopoData; + i < MAP_WIDTH * MAP_HEIGHT; + ++i, ++elev) + { + *elev -= 128; + } } else { // no elevation data -- planet flat as a pancake