Beispiel #1
0
        /// <summary>
        /// Returns field from array (of normal step size) of the given class on the given index
        /// </summary>
        public CField GetField(EClass pClass, int pX, int pY)
        {
            switch (pClass)
            {
            case EClass.Unassigned:
                return(unassignedArray.GetField(pX, pY));

            case EClass.Ground:
                return(groundArray.GetField(pX, pY));

            case EClass.Vege:
                return(vegeArray.GetField(pX, pY));

            case EClass.Building:
                return(buildingArray.GetField(pX, pY));
            }
            CDebug.Error($"array from class {pClass} not defined");
            return(null);
        }
Beispiel #2
0
        public static void Export(int pTileIndex)
        {
            if (!exportBitmap)
            {
                return;
            }

            //init for each tile
            treeMarkerSize = GetTreeBrushSize(false);

            DateTime bitmapStart = DateTime.Now;

            CVegeArray array  = CProjectData.Points.vegeDetailArray;
            Bitmap     bitmap = new Bitmap(array.arrayXRange, array.arrayYRange);

            int maxValue = 0;

            for (int x = 0; x < array.arrayXRange; x++)
            {
                for (int y = 0; y < array.arrayYRange; y++)
                {
                    CVegeField element  = array.GetField(x, y);
                    int?       colorVal = element.GetColorValue();               //from detailed array

                    if (colorVal == null)
                    {
                        continue;
                    }

                    int colorVaInt = (int)colorVal;
                    if (colorVaInt > maxValue)
                    {
                        maxValue = colorVaInt;
                    }

                    int rVal = colorVaInt;
                    //highlight buffer zone
                    bool isAtBufferZone = CTreeMath.IsAtBufferZone(element.Center);
                    if (isAtBufferZone)
                    {
                        rVal = Math.Min(rVal + 30, 255);
                    }

                    Color color = Color.FromArgb(rVal, colorVaInt, colorVaInt);
                    //CDebug.WriteLine($"{x},{y} = {color}");

                    bitmap.SetPixel(x, y, color);


                    if (exportMain && !isAtBufferZone)
                    {
                        Tuple <int, int> posInMain = GetIndexInMainBitmap(element.Center);

                        if (posInMain == null)
                        {
                            continue;
                        }

                        if (color.R > 255)
                        {
                            CDebug.Error("color.R = " + color.R);
                        }
                        mainMap.SetPixel(posInMain.Item1, posInMain.Item2, color);
                    }
                }
            }

            //StretchColorRange(ref bitmap, maxValue);

            //FilterBitmap(ref bitmap, GetKernelSize(array.stepSize, .2f), EFilter.Max);

            if (exportHeightmap)
            {
                ExportBitmap(bitmap, "heightmap", pTileIndex);
            }

            int  bitmapsCount = 3;
            bool useCheckTree = CParameterSetter.GetBoolSettings(ESettings.useCheckTreeFile);

            if (useCheckTree)
            {
                bitmapsCount++;
            }

            CDebug.Progress(1, bitmapsCount, 1, ref bitmapStart, bitmapStart, "bitmap: ");

            if (exportPositions)
            {
                Bitmap bitmapTreePos = new Bitmap(bitmap);
                AddTreesToBitmap(array, bitmapTreePos, true, false);
                ExportBitmap(bitmapTreePos, "tree_positions", pTileIndex);

                if (useCheckTree)
                {
                    Bitmap bitmapChecktree = new Bitmap(bitmapTreePos);
                    ExportBitmap(bitmapChecktree, "tree_check", pTileIndex);
                    CDebug.Progress(bitmapsCount - 1, bitmapsCount, 1, ref bitmapStart, bitmapStart, "bitmap: ");
                }
            }

            CDebug.Progress(2, bitmapsCount, 1, ref bitmapStart, bitmapStart, "bitmap: ");

            if (exportBorders)
            {
                Bitmap bitmapTreeBorder = new Bitmap(bitmap);
                AddTreesToBitmap(array, bitmapTreeBorder, true, true);
                ExportBitmap(bitmapTreeBorder, "tree_borders", pTileIndex);
            }

            CDebug.Progress(bitmapsCount, bitmapsCount, 1, ref bitmapStart, bitmapStart, "bitmap: ");

            CAnalytics.bitmapExportDuration = CAnalytics.GetDuration(bitmapStart);
            CDebug.Duration("bitmap export", bitmapStart);
        }