コード例 #1
0
        public void SaveRegionWorldMapTile(IScene scene, string fileName, int size)
        {
            m_Generator = scene.RequestModuleInterface <IMapImageGenerator> ();
            if (m_Generator == null)
            {
                return;
            }

            Bitmap bmp = m_Generator.CreateViewTileImage(size);

            if (bmp == null)
            {
                return;
            }

            var          regionName = scene.RegionInfo.RegionName;
            Bitmap       outbmp     = ResizeBitmap(bmp, size, size, regionName);
            MemoryStream str        = new MemoryStream();

            outbmp.Save(str, ImageFormat.Jpeg);             // default quality is about 75
            byte [] jpeg = str.ToArray();

            // save image
            var savePath = fileName;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = regionName + "_maptile.jpg";
                savePath = PathHelpers.VerifyWriteFile(fileName, ".jpg", simulationBase.DefaultDataPath + "/Worldview", true);
            }
            File.WriteAllBytes(savePath, jpeg);

            bmp.Dispose();
            outbmp.Dispose();
        }
コード例 #2
0
        public byte[] ExportWorldMapTile(int size)
        {
            Bitmap bmp = m_Generator.CreateViewTileImage(size);

            if (bmp != null)
            {
                MemoryStream str = new MemoryStream();

                bmp.Save(str, ImageFormat.Jpeg);

                return(str.ToArray());
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        public void SaveRegionWorldMapTile(IScene scene, string fileName, int size)
        {
            // if different formats etc are needed
            //var imgEncoder = GetEncoderInfo ("image/jpeg");
            //var encQuality = Encoder.Quality;
            //var encParms = new EncoderParameters (1);
            //encParms.Param[0] = new EncoderParameter (encQuality, 50L);

            m_Generator = scene.RequestModuleInterface <IMapImageGenerator> ();
            if (m_Generator == null)
            {
                return;
            }

            Bitmap bmp = m_Generator.CreateViewTileImage(size);

            if (bmp == null)
            {
                return;
            }

            var          regionName = scene.RegionInfo.RegionName;
            Bitmap       outbmp     = ResizeBitmap(bmp, size, size, regionName);
            MemoryStream str        = new MemoryStream();

            outbmp.Save(str, ImageFormat.Jpeg);             // default quality is about 75
            //outbmp.Save(str, imgEncoder, encParms);       // if encoder parms is used
            byte [] jpeg = str.ToArray();

            // save image
            var savePath = fileName;

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = regionName + "_maptile.jpg";
                savePath = PathHelpers.VerifyWriteFile(fileName, ".jpg", simulationBase.DefaultDataPath + "/Worldview", true);
            }
            File.WriteAllBytes(savePath, jpeg);

            bmp.Dispose();
            outbmp.Dispose();
        }
コード例 #4
0
        public void SaveRegionWorldMapTile (IScene scene, string fileName, int size)
        {
            // if different formats etc are needed
            //var imgEncoder = GetEncoderInfo ("image/jpeg");
            //var encQuality = Encoder.Quality;
            //var encParms = new EncoderParameters (1);
            //encParms.Param[0] = new EncoderParameter (encQuality, 50L);

            m_Generator = scene.RequestModuleInterface<IMapImageGenerator> ();
            if (m_Generator == null)
                return;

            Bitmap bmp = m_Generator.CreateViewTileImage (size);
            if (bmp == null)
                return;

            var regionName = scene.RegionInfo.RegionName;
            Bitmap outbmp = ResizeBitmap (bmp, size, size, regionName);
            MemoryStream str = new MemoryStream ();
            outbmp.Save (str, ImageFormat.Jpeg);            // default quality is about 75
            //outbmp.Save(str, imgEncoder, encParms);       // if encoder parms is used
            byte [] jpeg = str.ToArray ();

            // save image
            var savePath = fileName;
            if (string.IsNullOrEmpty (fileName)) {
                fileName = regionName + "_maptile.jpg";
                savePath = PathHelpers.VerifyWriteFile (fileName, ".jpg", simulationBase.DefaultDataPath + "/Worldview", true);
            }
            File.WriteAllBytes (savePath, jpeg);

            bmp.Dispose ();
            outbmp.Dispose ();
        }