Esempio n. 1
0
        /// <summary>
        /// generate the bitmap of a region
        /// </summary>
        /// <param name="bbox">requested rendering boundary</param>
        /// <param name="height">height of the bitmap</param>
        /// <param name="width">width of the bitmap</param>
        /// <returns></returns>
        public Bitmap generateMapRegionImg()
        {
            Bitmap mapRegionImg = new Bitmap(MapRegionImg.Width, MapRegionImg.Height);

            try
            {
                int width  = MapRegionImg.Width;
                int height = MapRegionImg.Height;

                Graphics gf = Graphics.FromImage((Image)mapRegionImg);

                List <Bitmap> layerBatches = new List <Bitmap>();

                if (m_hasTerrainLyr)
                {
                    layerBatches.Add(m_terrainLyr.render(MapRegionBBox, width, height, Elevation));
                }
                if (m_hasObjLyr)
                {
                    layerBatches.Add(m_objLyr.render(MapRegionBBox, width, height, Elevation));
                }
                if (m_hasAgentLyr)
                {
                    layerBatches.Add(m_agentLyr.render(MapRegionBBox, width, height, Elevation));
                }

                for (int i = 0; i < layerBatches.Count; i++)
                {
                    gf.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected;
                    //determine the overwrite mode
                    gf.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                    gf.DrawImage(layerBatches[i], new Rectangle(0, 0, width, height));
                    layerBatches[i].Dispose();
                }
                gf.Dispose();
            }
            catch (Exception e)
            {
                throw new Exception("generate map region image failed, " + e.Message);
            }

            MapRegionImg.MapRegionBmp = mapRegionImg;
            return(mapRegionImg);
        }