public void ConvertMazeToImage_SuperSimpleMazeRoundTrip_AllPixelColorsAndPositionsMatch() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMaze.png"; const bool useEmbeddedColorManagement = true; var originalImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); var maze = MazeConverter.ConvertImageToMaze(originalImage); const string mazeImageFileSavePath = @"..\..\..\TestingMazes\SuperSimpleMazeTest2.png"; var mazeWriter = new MazeWriterUtility(mazeImageFileSavePath, maze); mazeWriter.SaveMazeImage(); var newImage = Image.FromFile(mazeImageFileSavePath, useEmbeddedColorManagement); var mazeHeight = originalImage.Height; var mazeWidth = originalImage.Width; var originalBitmap = new Bitmap(originalImage); var newBitmap = new Bitmap(newImage); for (var x = 0; x < mazeWidth; x++) { for (var y = 0; y < mazeHeight; y++) { var originalPixelColor = originalBitmap.GetPixel(x, y); var newPixelColor = newBitmap.GetPixel(x, y); Assert.AreEqual(originalPixelColor.ToArgb(), newPixelColor.ToArgb()); } } }
public void ConvertImageToMaze_MazeHasNoFinishPoint_ThrowsException() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMazeNoEnd.png"; const bool useEmbeddedColorManagement = true; var mazeImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); MazeConverter.ConvertImageToMaze(mazeImage); }
public void ConvertImageToMaze_ColorsAreUnsupportedShadeOfBlue_ThrowsException() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMazePurpleEnd.png"; const bool useEmbeddedColorManagement = true; var mazeImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); MazeConverter.ConvertImageToMaze(mazeImage); }
public void ConvertImageToMaze_ColorsAreInvalid_ThrowsException() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SmileyFace.png"; const bool useEmbeddedColorManagement = true; var mazeImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); MazeConverter.ConvertImageToMaze(mazeImage); }
public Maze ReadInMazeImage() { var useEmbeddedColorManagement = true; var mazeImage = Image.FromFile(MazeImageFilePath, useEmbeddedColorManagement); var maze = MazeConverter.ConvertImageToMaze(mazeImage); return(maze); }
public MainWindowViewModel() { const bool useEmbeddedColorManagement = true; _mazeImage = Image.FromFile(_mazeImageFilePath, useEmbeddedColorManagement); _mazeToSolve = MazeConverter.ConvertImageToMaze(_mazeImage); var mazeImageBitmap = new Bitmap(_mazeImage); MazeImageBitmapSource = MazeRedrawnListener.BitmapToBitmapSource(mazeImageBitmap); InstantiateMazeSolutionLogicList(); }
public void ConvertImageToMaze_SuperSimpleMaze_MazeGridpointsMatchHeightTimesWidth() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMaze.png"; const bool useEmbeddedColorManagement = true; var mazeImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); var maze = MazeConverter.ConvertImageToMaze(mazeImage); var mazeHeight = mazeImage.Height; var mazeWidth = mazeImage.Width; Assert.AreEqual(maze.MazeGridpoints.Count, mazeHeight * mazeWidth); }
private void SolveMazeOnThread() { // If the maze image has already been solved, this will reset it var mazeImageBitmap = new Bitmap(_mazeImage); MazeImageBitmapSource = MazeRedrawnListener.BitmapToBitmapSource(mazeImageBitmap); var mazeRedrawnListener = new MazeRedrawnListener(); try { _isBusySolving = true; // Subscribed to the event to watch the maze get solved if (WatchMazeGetSovled) { mazeRedrawnListener.Subscribe(_selectedSolverLogic, this); // Pretreatment logic is not very fun to watch _selectedSolverLogic.PreTreatmentLogics.Clear(); } _selectedSolverLogic.SolveMaze(); _selectedSolverLogic.MarkSolutionPath(); var mazeWriter = new MazeWriterUtility(MazeSolutionImageFilePath, _selectedSolverLogic.MazeToSolve); mazeWriter.SaveMazeImage(); // This should dispaly the solved path on the maze highlighted in green mazeImageBitmap = new Bitmap(mazeWriter.MazeImage); MazeImageBitmapSource = MazeRedrawnListener.BitmapToBitmapSource(mazeImageBitmap); } catch (Exception exceptionCaught) { throw exceptionCaught; } finally { _isBusySolving = false; mazeRedrawnListener.UnSubscribe(_selectedSolverLogic); const bool useEmbeddedColorManagement = true; _mazeImage = Image.FromFile(_mazeImageFilePath, useEmbeddedColorManagement); _mazeToSolve = MazeConverter.ConvertImageToMaze(_mazeImage); InstantiateMazeSolutionLogicList(); } }
public void ConvertMazeToImage_SuperSimpleMaze_MazeGridpointsMatchHeightTimesWidth() { const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMaze.png"; const bool useEmbeddedColorManagement = true; var originalImage = Image.FromFile(mazeImageFilePath, useEmbeddedColorManagement); var maze = MazeConverter.ConvertImageToMaze(originalImage); const string mazeImageFileSavePath = @"..\..\..\TestingMazes\SuperSimpleMazeTest1.png"; var mazeWriter = new MazeWriterUtility(mazeImageFileSavePath, maze); mazeWriter.SaveMazeImage(); var newImage = Image.FromFile(mazeImageFileSavePath, useEmbeddedColorManagement); var mazeHeight = newImage.Height; var mazeWidth = newImage.Width; Assert.AreEqual(maze.MazeGridpoints.Count, mazeHeight * mazeWidth); }