/// <summary> Open an image file into the picture box control </summary> private void miFileOpen_Click(object sender, EventArgs e) { Image image = ImageDialogToolbox.ShowOpenImageDialog(ref _dir, ref _currentFile); if (image == null) { return; // if the user did not select a file, return } Text = $"Watermark Utility: {_currentFile}"; ChangeCurrentImage(image); EnableBasedOnImage(); }
/// <summary> Save the Current Image with the Watermark </summary> private void miFileSave_Click(object sender, EventArgs e) { DialogResult dr = ImageDialogToolbox.ShowSaveDialog(ref _currentFile); if ((dr == DialogResult.Cancel) || (dr == DialogResult.Abort)) { return; } ImageActionToolbox.SaveImage(_currentImage, _currentFile); picContainer.Image = Image.FromFile(_currentFile); // reload image from file Text = $"Watermark Utility: {_currentFile}"; }
/// <summary> Takes existing image and overlays image over top in the center </summary> /// <param name="currentImage">Existing Image </param> /// <param name="dir">Default directory to look for overlay image </param> /// <returns>True if overlay happened, False if error.</returns> internal static bool OverlayChosenImage(ref Image currentImage, ref string dir) { // ASSUMES the current image is the background and the image you are opening is the overlay image. string overlayFile = ""; Image imageOverlay = ImageDialogToolbox.ShowOpenImageDialog(ref dir, ref overlayFile); if (imageOverlay == null) { return(false); // if the user did not select a file, return } currentImage = Overlay(currentImage, imageOverlay); return(true); }
/// <summary> Switches all pixels of one chosen color to another. /// Warning - Transparent color areas will look like background color, but have a different ARGB from their solid cousins. </summary> /// <param name="currentImage">Image</param> internal static void ChooseToSwitchColor(ref Image image) { Color oldColor = Sable(); // default to solid black DialogResult drOld = ImageDialogToolbox.ShowColorDialogWithTitle("Pick Old Color To Switch", ref oldColor); if (drOld == DialogResult.Cancel) { return; } Color newColor = SolidWhite(); // default to solid white DialogResult drNew = ImageDialogToolbox.ShowColorDialogWithTitle("Pick New Color", ref newColor); if (drNew == DialogResult.Cancel) { return; } SwitchColor(ref image, oldColor, newColor); }
internal static bool SetWatermarkFont(ref Font currentWatermarkFont, ref Color currentWatermarkColor) { DialogResult dr = ImageDialogToolbox.ShowFontDialog(ref currentWatermarkFont, ref currentWatermarkColor); return(dr != DialogResult.Cancel); }