// creates PGM image object to flip private Image createFlippedImage() { var flippedImage = new PGM(); flippedImage.magicNumber = this.magicNumber; flippedImage.depth = this.depth; // flipping image will keep number of columns and number of rows as is. flippedImage.rows = this.rows; flippedImage.columns = this.columns; flippedImage.pixels = new string[rows, columns]; return flippedImage; }
// create PGM image object to rotate private Image createRotateImage() { var rotateImage = new PGM(); rotateImage.magicNumber = this.magicNumber; rotateImage.depth = this.depth; // rotating image will switch number of columns to number of rows and number of rows to number of columns rotateImage.rows = this.columns; rotateImage.columns = this.rows; rotateImage.pixels = new string[columns, rows]; return rotateImage; }
private static void ProcessPGMMenu() { var pgm = new PGM(); pgm.open(string.Format("{0}\\{1}", ConfigurationManager.AppSettings["PGMFileDirectory"], ConfigurationManager.AppSettings["PGMSourceFile"])); ConsoleKeyInfo cki; var file = string.Empty; do { DisplayPGMMenu(); cki = Console.ReadKey(false); switch (cki.KeyChar.ToString()) { case "1": file = pgm .rotateRight() .save("PGM-RightRotated"); Console.WriteLine(string.Format("{0} PGM file created with Right rotation.", file)); break; case "2": file = pgm .rotateLeft() .save("PGM-LeftRotated"); Console.WriteLine(string.Format("{0} PGM file created with Left rotation.", file)); break; case "3": file = pgm .flipVertical() .save("PGM-VerticalFlipped"); Console.WriteLine(string.Format("{0} PGM file created by filipping vertically.", file)); break; case "4": file = pgm .flipHorizontal() .save("PGM-HorizontalFlipped"); Console.WriteLine(string.Format("{0} PGM file created by flipping horizontally.", file)); break; default: if (cki.Key == ConsoleKey.Escape) { Console.WriteLine("\nReturning back to main menu."); } else { Console.WriteLine("Unkonwn menu option entered."); } break; } } while (cki.Key != ConsoleKey.Escape); }