/// <summary> /// iView.NET subroutine. Allows the user to remove or reduce the red eye from the specified region within the specified image. /// </summary> /// <param name="nX"></param> /// <param name="nY"></param> /// <returns></returns> private SResult SubRedEyeCorrectionTool(int nX, int nY) { if (!imgbx_MainImage.IsImageLoaded) return SResult.NullDisplayImage; int nImageWidth = imgbx_MainImage.ImageBoxImage.Width; int nImageHeight = imgbx_MainImage.ImageBoxImage.Height; int nBoxWidth = imgbx_MainImage.ImageBoxWidth; int nBoxHeight = imgbx_MainImage.ImageBoxHeight; // Translate the current x position. float fXPercent = 100 / ((float)nBoxWidth / (float)nX); float fX = (fXPercent / 100) * nImageWidth; // Translate the current y position. float fYPercent = 100 / ((float)nBoxHeight / (float)nY); float fY = (fYPercent / 100) * nImageHeight; int nPos = (m_oRedEyePanel.PupilSize / 2); Rectangle Rect = new Rectangle((int)fX - nPos, (int)fY - nPos, m_oRedEyePanel.PupilSize, m_oRedEyePanel.PupilSize); // Update the image edited status. ImageHasBeenEdited = true; // No elements in the list? Save the original state first. if (m_oUndoRedo.Count == 0) m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); // Process the image. using (ImageProcessing oProcess = new ImageProcessing(imgbx_MainImage.ImageBoxImage)) { // Apply the red eye correction. oProcess.RedEyeCorrection(Rect, 1.5f); // Update the main display image with the edited image. imgbx_MainImage.ImageBoxImage = oProcess.GetProcessedImage(); } // Save the current image state. m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); // Reset the current tool and cursor. m_nCurrentTool = Tool.None; imgbx_MainImage.Cursor = Cursors.Default; return SResult.Completed; }