Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titleMap2bmp
sdp = SlamwareCorePlatform::connect(opt_sdpIPAddress, opt_sdpPort);   
     
rpos::core::RectangleF knownArea = sdp.getKnownArea(MapTypeBitmap8Bit, rpos::features::location_provider::EXPLORERMAP); //获得地图已知区域

Map map = sdp.getMap(MapTypeBitmap8Bit, knownArea, rpos::features::location_provider::EXPLORERMAP);//根据地图已知区域,获得地图


bitmap_image mapBitmap(map.getMapDimension().x(), map.getMapDimension().y()); //根据已获得的地图尺寸,定义bmp


for (size_t posY = 0; posY < map.getMapDimension().y(); ++posY) //获取mapdata数据,并转化成bmp
{
   for (size_t posX = 0; posX < map.getMapDimension().x(); ++posX)
   {
      rpos::system::types::_u8 cellValue = 128 + map.getMapData()[posX + (map.getMapDimension().y()-posY-1) * map.getMapDimension().x()];
      mapBitmap.set_pixel(posX, posY, cellValue, cellValue, cellValue);
   }
}

...