}//invert private void flipVertical_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 <int> > newImageList; newImageList = PPMImageLibrary.TransformFlipVertical( 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; } //invert
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; }
}//cmdFS1 // // Save as: // private void cmdSaveAs_Click(object sender, EventArgs e) { if (CurrentImage == null) // sanity check: make sure we have an image to save { return; } saveFileDialog1.Filter = "PPM Files (*.ppm)|*.ppm"; saveFileDialog1.DefaultExt = "ppm"; saveFileDialog1.FileName = ""; saveFileDialog1.InitialDirectory = System.Environment.CurrentDirectory; DialogResult dr = saveFileDialog1.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { string filepath = saveFileDialog1.FileName; bool written = PPMImageLibrary.WriteP3Image( filepath, CurrentImage.Header.Width, CurrentImage.Header.Height, CurrentImage.Header.Depth, CurrentImage.ImageListData ); if (!written) { MessageBox.Show("Write failed?!"); } } else { MessageBox.Show("Save As was canceled..."); } }//cmdSaveAs