private static Bitmap FilterImage(RealBlueprint pRealBlueprint, Size pBlueprintSize) { var filters = new List<Func<Bitmap, Bitmap>> { ImageProcessor.ApplyGrayScaleFilter, ImageProcessor.ApplyBinarization, ImageProcessor.ApplyInvert, ImageProcessor.ApplyErosion, ImageProcessor.ApplyInvert, ImageProcessor.ApplyImageSmoothing, ImageProcessor.ApplyErosion, ImageProcessor.ApplyFillHoles }; var bitmap = ImageProcessor.ApplyFilters(pRealBlueprint.Bitmap, filters); return ImageProcessor.ResizeImage(bitmap, (int)pBlueprintSize.Width, (int)pBlueprintSize.Height); }
private void GenerateBlueprintFromImage(RealBlueprint pRealBlueprint) { mRealSize = pRealBlueprint.Size; Cells = AdjustNewCellArea(); BlueprintCreator.MapBlueprintToCells(mCells, new Size(CellAreaWidth, CellAreaHeight), pRealBlueprint); }
public static void MapBlueprintToCells(List<List<Cell>> pCells, Size pBlueprintSize, RealBlueprint pRealBlueprint) { var bitmap = FilterImage(pRealBlueprint, pBlueprintSize); SetObstacles(pCells, bitmap, pRealBlueprint.DefaultObstacle); }
/// <summary> /// Creates new blueprint based on real building image. /// </summary> public void CreateNewBlueprint(RealBlueprint pRealBlueprint) { ClearBlueprint(); GenerateBlueprintFromImage(pRealBlueprint); CreationDate = DateTime.Now; if (BlueprintCreated != null) BlueprintCreated(this, new EventArgs()); Log.Write(LogLevel.Info, string.Format("Plan budynku wygenerowany o godzinie: {0}", CreationDate)); }