// create image private Image createImage() { var image = new PPM(); image.magicNumber = this.magicNumber; image.depth = this.depth; // flipping image will keep number of columns and number of rows as is. image.rows = this.rows; image.columns = this.columns; image.pixels = new Color[rows, columns]; return image; }
// create PPM image object to rotate private Image createRotateImage() { var rotateImage = new PPM(); 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 Color[columns, rows]; return rotateImage; }
private static void ProcessPPMMenu() { var ppm = new PPM(); ppm.open(string.Format("{0}\\{1}", ConfigurationManager.AppSettings["PPMFileDirectory"], ConfigurationManager.AppSettings["PPMSourceFile"])); var selectedOption = string.Empty; var file = string.Empty; do { DisplayPPMMenu(); selectedOption = Console.ReadLine(); switch (selectedOption) { case "1": file = ppm .rotateRight() .save("PPM-RightRotated"); Console.WriteLine(string.Format("{0} PPM file created with Right rotation.", file)); break; case "2": file = ppm .rotateLeft() .save("PPM-LeftRotated"); Console.WriteLine(string.Format("{0} PPM file created with Left rotation.", file)); break; case "3": file = ppm .flipVertical() .save("PPM-VerticalFlipped"); Console.WriteLine(string.Format("{0} PPM file created by filipping vertically.", file)); break; case "4": file = ppm .flipHorizontal() .save("PPM-HorizontalFlipped"); Console.WriteLine(string.Format("{0} PPM file created by flipping horizontally.", file)); break; case "5": file = ppm .negateRed() .save("PPM-NegateRed"); Console.WriteLine(string.Format("{0} PPM file created by negating red.", file)); break; case "6": file = ppm .negateGreen() .save("PPM-NegateGreen"); Console.WriteLine(string.Format("{0} PPM file created by negating green.", file)); break; case "7": file = ppm .negateBlue() .save("PPM-NegateBlue"); Console.WriteLine(string.Format("{0} PPM file created by negating blue.", file)); break; case "8": file = ppm .GreyScale() .save("PPM-GreyScale"); Console.WriteLine(string.Format("{0} PPM file created by scaling upto grey.", file)); break; case "9": file = ppm .flattenRed() .save("PPM-FlattenRed"); Console.WriteLine(string.Format("{0} PPM file created by flatten red.", file)); break; case "10": file = ppm .flattenGreen() .save("PPM-flattenGreen"); Console.WriteLine(string.Format("{0} PPM file created by flatten green.", file)); break; case "11": file = ppm .flattenBlue() .save("PPM-FlattenBlue"); Console.WriteLine(string.Format("{0} PPM file created by flatten blue.", file)); break; case "12": file = ppm .convertToPGM() .save("PPM-To-PGM-ConvertedFile"); Console.WriteLine(string.Format("{0} PPM file converted into PGM file.", file)); break; case "13": file = ppm .horizontalBlur() .save("PPM-HorizontalBlur"); Console.WriteLine(string.Format("{0} PPM file horizontally blured.", file)); break; case "14": file = ppm .extremeContrast() .save("PPM-ExtremeContrast"); Console.WriteLine(string.Format("{0} PPM file extremely contrasted.", file)); break; case "15": file = ppm .randomNoise() .save("PPM-RandomeNoise"); Console.WriteLine(string.Format("{0} PPM file with random noise.", file)); break; default: if (selectedOption == "X") { Console.WriteLine("\nReturning back to main menu."); } else { Console.WriteLine("Unkonwn menu option entered."); } break; } } while (selectedOption != "X"); }