// // Open: // private void cmdOpen_Click(object sender, EventArgs e) { openFileDialog1.Filter = "PPM Files (*.ppm)|*.ppm|All files (*.*)|*.*"; openFileDialog1.FileName = ""; openFileDialog1.CheckFileExists = true; openFileDialog1.InitialDirectory = System.Environment.CurrentDirectory; DialogResult dr = openFileDialog1.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { string filepath = openFileDialog1.FileName; CurrentImage = new PixelMap(filepath); picImage.Image = CurrentImage.BitMap; // enable the other buttons so user can manipulate image: cmdFS1.Enabled = true; cmdSaveAs.Enabled = true; button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; //button5.Enabled = true; } else { MessageBox.Show("Open was canceled..."); } }//cmdOpen
private void button4_Click(object sender, EventArgs e) { if (CurrentImage == null) // sanity check: make sure we have an image to manipulate { return; } // // Example of calling library, which then dumps data about the given image // to Visual Studio's "Output" window. Note you must run with debugging (F5) // in order to see the output. // //PPMImageLibrary.DebugOutput( // CurrentImage.Header.Width, // CurrentImage.Header.Height, // CurrentImage.Header.Depth, // CurrentImage.ImageListData //); // // we have an image, perform transformation and display new result: // FSharpList <FSharpList <Tuple <int, int, int> > > newImageList; int factor; bool success = System.Int32.TryParse(txtFactor.Text, out factor); if (!success) { factor = 2; txtFactor.Text = factor.ToString(); } newImageList = PPMImageLibrary.Zoom( CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData, factor ); // // create a new PixelMap here on the client-side, which creates a new bitmap // we then display to the user: // CurrentImage = new PixelMap(newImageList); picImage.Image = CurrentImage.BitMap; }
private void button1_Click(object sender, EventArgs e) { if (CurrentImage == null) // sanity check: make sure we have an image to manipulate return; // // Example of calling library, which then dumps data about the given image // to Visual Studio's "Output" window. Note you must run with debugging (F5) // in order to see the output. // //PPMImageLibrary.DebugOutput( // CurrentImage.Header.Width, // CurrentImage.Header.Height, // CurrentImage.Header.Depth, // CurrentImage.ImageListData //); // // Perform transformation: // FSharpList<FSharpList<int>> newImageList; //System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); //stopWatch.Start(); newImageList = PPMImageLibrary.TransformGrayscale( CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData ); // // create a new PixelMap here on the client-side, which creates a new bitmap // we then display to the user: // CurrentImage = new PixelMap(newImageList); picImage.Image = CurrentImage.BitMap; //stopWatch.Stop(); //TimeSpan ts = stopWatch.Elapsed; //string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); //MessageBox.Show("Time Elapsed: "+elapsedTime); }
private void button5_Click(object sender, EventArgs e) { int number = int.Parse(textBox1.Text); if (CurrentImage == null) // sanity check: make sure we have an image to manipulate { return; } // // Example of calling library, which then dumps data about the given image // to Visual Studio's "Output" window. Note you must run with debugging (F5) // in order to see the output. // //PPMImageLibrary.DebugOutput( // CurrentImage.Header.Width, // CurrentImage.Header.Height, // CurrentImage.Header.Depth, // CurrentImage.ImageListData //); // // Perform transformation: // FSharpList <FSharpList <int> > newImageList; // newImageList = PPMImageLibrary.Zoom( CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData, number ); // // create a new PixelMap here on the client-side, which creates a new bitmap // we then display to the user: // CurrentImage = new PixelMap(newImageList); picImage.Image = CurrentImage.BitMap; }
}//cmdOpen // // Test F#: // private void cmdFS1_Click(object sender, EventArgs e) { if (CurrentImage == null) // sanity check: make sure we have an image to manipulate { return; } // // Example of calling library, which then dumps data about the given image // to Visual Studio's "Output" window. Note you must run with debugging (F5) // in order to see the output. // //PPMImageLibrary.DebugOutput( // CurrentImage.Header.Width, // CurrentImage.Header.Height, // CurrentImage.Header.Depth, // CurrentImage.ImageListData //); // // we have an image, perform transformation and display new result: // FSharpList <FSharpList <Tuple <int, int, int> > > newImageList; newImageList = PPMImageLibrary.TransformFirstThreeRows( CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData ); // // create a new PixelMap here on the client-side, which creates a new bitmap // we then display to the user: // CurrentImage = new PixelMap(newImageList); picImage.Image = CurrentImage.BitMap; }//cmdFS1
private void button2_Click(object sender, EventArgs e) { if (CurrentImage == null) // sanity check: make sure we have an image to manipulate return; // // Example of calling library, which then dumps data about the given image // to Visual Studio's "Output" window. Note you must run with debugging (F5) // in order to see the output. // //PPMImageLibrary.DebugOutput( // CurrentImage.Header.Width, // CurrentImage.Header.Height, // CurrentImage.Header.Depth, // CurrentImage.ImageListData //); // // Perform transformation: // FSharpList<FSharpList<int>> newImageList; newImageList = PPMImageLibrary.TransformInvert( CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData ); // // create a new PixelMap here on the client-side, which creates a new bitmap // we then display to the user: // CurrentImage = new PixelMap(newImageList); picImage.Image = CurrentImage.BitMap; }