ImageEditorUserControl.cs
Description du code
ImageEditorUserControl.cs est un fichier du projet PhotoBrol.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/photobrol/.
Projet PhotoBrol :
Editeur d'images en CSharp.
Code source ou contenu du fichier
Code c# (ImageEditorUserControl.cs) (1211 lignes)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using be.gaudry.photobrol.view.dialogs; using be.gaudry.view.dialogs; using be.gaudry.photobrol.model.filters; using System.IO; using System.Drawing.Imaging; using be.gaudry.model.drawing; using be.gaudry.model; using be.gaudry.model.config; namespace be.gaudry.photobrol.view.controls { public partial class ImageEditorUserControl : UserControl { #region constructor and declarations private BrolImage img, curImg; private History<BrolImage> imageHistory; private TrackIntParameterDialog trkIntDialog; private TrackFloatParameterDialog trkFloatDialog; private ImageFormat[] validImagesFormats; public ImageEditorUserControl() { InitializeComponent(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openFileDialog.Filter = "Fichiers Jpeg (*.jpg;*.jpeg)|*.jpg;*.jpeg|Fichiers bitmap (*.bmp)|*bmp|Tous les fichiers valides (*.jpg;*.jpeg;*.bmp)|*.jpg;*.jpeg;*.bmp"; saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); // saveFileDialog.Filter items MUST MATCHES validImagesFormats items order !!! saveFileDialog.Filter = "Fichiers Jpeg (*.jpg;*.jpeg)|*.jpg;*.jpeg|Fichiers bitmap (*.bmp)|*bmp"; { destopImgSizeModeCB.Items.Add(sizeMode); } if(destopImgSizeModeCB.Items.Count>0) destopImgSizeModeCB.SelectedIndex = 0; checkActions(); "Histograms", this.Name, "http://www.codeproject.com/cs/miscctrl/histogramcontrol.asp", "Informations sur l'utilisation des histogrammes" ) ); "EXIFextractor", this.Name, "http://www.codeproject.com/csharp/exifextractor.asp", "Extraction des informations EXIF des images" ) ); "Professional C#", this.Name, "http://www.codeproject.com/books/1861004990.asp", "Traitement GDI+" ) ); "ColorAvgLum selection", this.Name, "http://www.codeproject.com/cs/miscctrl/ColorPaletteControl.asp", "Création de palettes de couleurs" ) ); } #endregion #region properties /// <summary> /// Path of the start image /// </summary> [ Category("Image Editor options"), Description("Path of the start image") ] public String ImageLocation { get { return img.FullPath; } set { if (value != null) { if (img == null) else img.FullPath = value; initImage(); } } } /// <summary> /// Image to edit /// </summary> [ Category("Image Editor options"), Description("Image") ] public Image Image { get { return scrollPBUC.Bitmap; } set { if (img == null) if (value != null) { initImage(); } } } /// <summary> /// Image with informations /// </summary> [ Category("Image Editor options"), Description("Image with informations") ] public BrolImage BrolImage { get { return img; } set { if (value!=null) { if (value.Deep == 24) { img = value; initImage(); } else if (value.Deep != 0) { MessageBox.Show( this, String.Format("L'éditeur ne traite pas actuellement les images codées en {0} bits",value.Deep), "Erreur de chargement", MessageBoxButtons.OK, MessageBoxIcon.Information ); } } } } #endregion #region public methods public void setMenuStripDock(DockStyle dockStyle) { this.mainMenuStrip.Dock = dockStyle; } public void undo() { try { curImg = imageHistory.Undo; setHistoryDisplay(); scrollPBUC.Bitmap = curImg.Image; } catch (InvalidOperationException) { } } public void redo() { try { curImg = imageHistory.Redo; setHistoryDisplay(); scrollPBUC.Bitmap = curImg.Image; } catch (InvalidOperationException) { } } #endregion #region private image methods private void initImage() { if (img != null && curImg != null && img.Image!=null) { enableImgSettings(false); curImg.Image = img.Image; imagePG.SelectedObject = img; curImagePG.SelectedObject = curImg; imageHistory.clear(); imageHistory.go(curImg); scrollPBUC.Bitmap = curImg.Image; enableImgSettings(true); } checkActions(); setHistoryDisplay(); } private void setHistoryDisplay() { int undoCount = imageHistory.UndoCount; int redoCount = imageHistory.RedoCount; undoTSB.Enabled = (undoCount > 1);//the first item is set on load image annulerToolStripMenuItem.Enabled = undoTSB.Enabled; redoTSB.Enabled = (redoCount > 0); rétablirToolStripMenuItem.Enabled = redoTSB.Enabled; historyLbl.Text = String.Format("Opération {0}/{1}", undoCount, undoCount+redoCount); } private void setThumb() { imageHistory.go(curImg); setHistoryDisplay(); //scrollPBUC.Bitmap.Dispose(); scrollPBUC.Bitmap = curImg.Image; } private void checkActions() { bool basicFilterEnabled = ImageHelper.isImg(img.FullPath); foreach(ToolStripItem tsi in imageTsMi.DropDownItems) { tsi.Enabled = basicFilterEnabled; } ouvrirToolStripMenuItem.Enabled = true; filterTsMi.Enabled = basicFilterEnabled; foreach(ToolStripItem tsi in toolStrip1.Items) { tsi.Enabled = basicFilterEnabled; } openTSB.Enabled = true; mruTsSB.Enabled = mruTsSB.DropDownItems.Count>0; collapseTabsTSB.Enabled = true; saveAsTSMenuItem.Enabled = true; thumbCMS.Enabled = basicFilterEnabled; splitContainer1.Enabled = basicFilterEnabled; } private void scrollPBUC_EnabledChanged(object sender, EventArgs e) { if (scrollPBUC.Enabled) rgblHistogramUserControl1.GatherStatistics(scrollPBUC.Bitmap); //histogramUserControl1.GatherStatistics(scrollPBUC.Bitmap); } #endregion #region image filters groupbox private void invertAction(object sender, EventArgs e) { enableImgSettings(false); if (BitmapFilter.Invert(curImg.Image)) { setThumb(); } enableImgSettings(true); } private void grayScaleAction(object sender, EventArgs e) { enableImgSettings(false); if (BitmapFilter.GrayScale(curImg.Image)) { setThumb(); } enableImgSettings(true); } #endregion #region image settings tp private void enableImgSettings(bool enable) { /*scrollPBUC.Enabled = enable; foreach (Control c in settingsTP.Controls) { c.Enabled = enable; }*/ try { splitContainer1.Enabled = enable; this.Cursor = (enable)?Cursors.Default:Cursors.WaitCursor; } catch(ArgumentException) { System.Threading.Thread.Sleep(0); enableImgSettings(enable); } } private void editImageBtn_Click(object sender, EventArgs e) { Bitmap bmp = (Bitmap)img.Image.Clone(); if (bmp == null) return; enableImgSettings(false); if (!BitmapFilter.Brightness(bmp, brightnessTrkB.Value)) { enableImgSettings(true); bmp.Dispose(); return; } if (!BitmapFilter.Contrast(bmp, (sbyte)contrastTrkB.Value)) { enableImgSettings(true); bmp.Dispose(); return; } double red = (double)gamaRedTrkB.Value / 100; double green = (double)gamaGreenTrkB.Value / 100; double blue = (double)gamaBlueTrkB.Value / 100; if (BitmapFilter.Gamma(bmp, red,green,blue)) { curImg.Image.Dispose(); curImg.Image = (Bitmap)bmp.Clone(); setThumb(); } bmp.Dispose(); enableImgSettings(true); } private void brightnessTrkB_Scroll(object sender, EventArgs e) { brightnessTB.Text = brightnessTrkB.Value.ToString(); } private void brightnessTB_TextChanged(object sender, EventArgs e) { setTrkValues(brightnessTrkB, brightnessTB); } private void contrastTrkB_Scroll(object sender, EventArgs e) { contrastTB.Text = contrastTrkB.Value.ToString(); } private void contrastTB_TextChanged(object sender, EventArgs e) { setTrkValues(contrastTrkB, contrastTB); } private void gamaRedTrkB_Scroll(object sender, EventArgs e) { gamaRedTB.Text = gamaRedTrkB.Value.ToString(); } private void gamaRedTB_TextChanged(object sender, EventArgs e) { setTrkValues(gamaRedTrkB, gamaRedTB); } private void gamaGreenTrkB_Scroll(object sender, EventArgs e) { gamaGreenTB.Text = gamaGreenTrkB.Value.ToString(); } private void gamaGreenTB_TextChanged(object sender, EventArgs e) { setTrkValues(gamaGreenTrkB, gamaGreenTB); } private void gamaBlueTrkB_Scroll(object sender, EventArgs e) { gamaBlueTB.Text = gamaBlueTrkB.Value.ToString(); } private void gamaBlueTB_TextChanged(object sender, EventArgs e) { setTrkValues(gamaBlueTrkB, gamaBlueTB); } private void setTrkValues(TrackBar trkB, TextBox tB) { int i; if (Int32.TryParse(tB.Text, out i) && i > trkB.Minimum && i < trkB.Maximum) { trkB.Value = i; } else { tB.Text = trkB.Value.ToString(); } } #endregion #region flip and rotations private void rotate90hTSB_Click(object sender, EventArgs e) { curImg.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); setThumb(); } private void rotate90ahTSB_Click(object sender, EventArgs e) { curImg.Image.RotateFlip(RotateFlipType.Rotate270FlipNone); setThumb(); } private void flipxTSB_Click(object sender, EventArgs e) { curImg.Image.RotateFlip(RotateFlipType.RotateNoneFlipX); setThumb(); } private void flipyTSB_Click(object sender, EventArgs e) { curImg.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); setThumb(); } #endregion #region desktop private void desktopColorBtn_Click(object sender, EventArgs e) { if (DialogResult.OK.Equals(colorDialog1.ShowDialog())) { desktopColorPanel.BackColor = colorDialog1.Color; } } private void wallpaperBtn_Click(object sender, EventArgs e) { img.FullPath, (Wallpaper.Affichage)Enum.Parse(typeof(Wallpaper.Affichage), destopImgSizeModeCB.SelectedItem.ToString()), desktopColorPanel.BackColor ); if (wallpaper.Afficher()) { MessageBox.Show( this, "Modifications effectuées.", "Configuration du bureau", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { MessageBox.Show( this, "Une erreur s'est produite lors de l'affichage du Wallpaper", "Configuration du bureau", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } #endregion #region zoom options private void zoomPosCmsMi_Click(object sender, EventArgs e) { scrollPBUC.zoomIn(); } private void zoomNegCmsMi_Click(object sender, EventArgs e) { scrollPBUC.zoomOut(); } private void zoomFitCmsMi_Click(object sender, EventArgs e) { scrollPBUC.zoomToFit(); } private void zoom100CmsMi_Click(object sender, EventArgs e) { scrollPBUC.zoomToRealSize(); } #endregion #region filters menu private void gaussianBlurTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Atténuation : Flou gaussien"; trkIntDialog.Info = "Effet de flou gaussien"; trkIntDialog.ValueInfo = "Angle : "; trkIntDialog.MinimumValue = 1; trkIntDialog.MaximumValue = 10; trkIntDialog.Value = 5; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.GaussianBlur(curImg.Image, trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void moreBlurTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Atténuation : Flou"; trkIntDialog.Info = "Effet de flou"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 1; trkIntDialog.MaximumValue = 5; trkIntDialog.Value = 1; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Smooth(curImg.Image, trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void brightnessTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Luminosité"; trkIntDialog.Info = "Réglage de la luminosité"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = -100; trkIntDialog.MaximumValue = 100; trkIntDialog.Value = 0; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Brightness(curImg.Image, trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void contrastTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Constraste"; trkIntDialog.Info = "Réglage du contraste"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = -100; trkIntDialog.MaximumValue = 100; trkIntDialog.Value = 0; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Contrast(curImg.Image, (sbyte)trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void meanRemovalTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Renforcement : Accentuation"; trkIntDialog.Info = "Filtre d'accentuation"; trkIntDialog.ValueInfo = "Accentué de : "; trkIntDialog.MinimumValue = 1; trkIntDialog.MaximumValue = 10; trkIntDialog.Value = 1; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.MeanRemoval(curImg.Image, trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void sharpenMore2TsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.MeanRemoval(curImg.Image, 9)) { setThumb(); } } enableImgSettings(true); } private void sharpenPTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Renforcement : Netteté optimisée"; trkIntDialog.Info = "Filtre de netteté optimisée"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 20; trkIntDialog.Value = 9; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.MeanRemoval(curImg.Image, trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void sharpenMoreTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.MeanRemoval(curImg.Image, 7)) { setThumb(); } } enableImgSettings(true); } private void embossTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (BitmapFilter.EmbossLaplacian(curImg.Image)) { setThumb(); } enableImgSettings(true); } private void edgeTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Esquisse : chrome"; trkIntDialog.Info = "Effet chrome"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 20; trkIntDialog.Value = 9; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeEnhance(curImg.Image, (byte)trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void edgeInvertTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Esquisse : crayon"; trkIntDialog.Info = "Effet crayon"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 1; trkIntDialog.MaximumValue = 10; trkIntDialog.Value = 5; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeDetectConvolution(curImg.Image, BitmapFilter.EDGE_DETECT_SOBEL, (byte)trkIntDialog.Value)) { if (BitmapFilter.Invert(curImg.Image)) { setThumb(); } } } enableImgSettings(true); } private void kirshTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Esquisse : tampon"; trkIntDialog.Info = "Effet tampon"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 10; trkIntDialog.Value = 5; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeDetectConvolution(curImg.Image, BitmapFilter.EDGE_DETECT_KIRSH, (byte)trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void prewittInvertTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Esquisse : fusain"; trkIntDialog.Info = "Effet fusain"; trkIntDialog.ValueInfo = "Valeur : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 10; trkIntDialog.Value = 1; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeDetectConvolution(curImg.Image, BitmapFilter.EDGE_DETECT_PREWITT, (byte)trkIntDialog.Value)) { if (BitmapFilter.Invert(curImg.Image)) { setThumb(); } } } enableImgSettings(true); } private void edgeVInvertTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeDetectVertical(curImg.Image)) { if (BitmapFilter.Invert(curImg.Image)) { setThumb(); } } } enableImgSettings(true); } private void edgeHInvertTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.EdgeDetectHorizontal(curImg.Image)) { if (BitmapFilter.Invert(curImg.Image)) { setThumb(); } } } enableImgSettings(true); } private void edgeEnhanceTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); if (BitmapFilter.EdgeEnhance(curImg.Image, (byte)10)) { setThumb(); } enableImgSettings(true); } private void resizeImageTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); rd.ParamWidth = curImg.Image.Width; rd.ParamHeight = curImg.Image.Height; if (rd.ShowDialog(this) == DialogResult.OK) { curImg.Image = BitmapFilter.Resize( curImg.Image, rd.ParamWidth, rd.ParamHeight, rd.ParamBilinear ); setThumb(); } enableImgSettings(true); } private void jitterTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Texture : grain"; trkIntDialog.Info = "Effet grain"; trkIntDialog.ValueInfo = "Intensité : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 20; trkIntDialog.Value = 5; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.RandomJitter(curImg.Image, (short)trkIntDialog.Value)) { setThumb(); } } enableImgSettings(true); } private void swirlTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkFloatDialog.Text = "Déformation : spirale"; trkFloatDialog.Info = "Effet spirale"; trkFloatDialog.ValueInfo = "Angle : "; trkFloatDialog.MinimumValue = 0F; trkFloatDialog.MaximumValue = 0.9F; trkFloatDialog.Value = 0.4F; trkFloatDialog.ValueChkBText = "Antialiasing"; trkFloatDialog.DisplayChkB = true; if (trkFloatDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Swirl(curImg.Image, trkFloatDialog.Value, trkFloatDialog.ValueChkBChecked)) { setThumb(); } } enableImgSettings(true); } private void sphereTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Déformation : sphère"; trkIntDialog.Info = "Effet sphère"; trkIntDialog.ValueInfo = "Déplacement : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 50; trkIntDialog.Value = 0; trkIntDialog.ValueChkB2Text = "Horizontal"; trkIntDialog.DisplayChkB2 = true; trkIntDialog.ValueChkB1Text = "Vertical"; trkIntDialog.DisplayChkB1 = true; trkIntDialog.ValueChkB3Text = "Antialiasing"; trkIntDialog.DisplayChkB3 = true; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { int vVal = (trkIntDialog.ValueChkB1Checked) ? trkIntDialog.Value : 0; int hVal = (trkIntDialog.ValueChkB2Checked) ? trkIntDialog.Value : 0; if (BitmapFilter.Sphere(curImg.Image, trkIntDialog.ValueChkB3Checked, vVal, hVal)) { setThumb(); } } enableImgSettings(true); } private void sphereNegTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Déformation : grand angle"; trkIntDialog.Info = "Effet grand angle"; trkIntDialog.ValueInfo = "Déplacement : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 50; trkIntDialog.Value = 0; trkIntDialog.ValueChkB1Text = "Antialiasing"; trkIntDialog.DisplayChkB1 = true; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Sphere(curImg.Image, trkIntDialog.ValueChkB1Checked, trkIntDialog.Value + 40, 0 - (trkIntDialog.Value + 40))) { setThumb(); } } enableImgSettings(true); } private void TimeWarpTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Déformation : contraction"; trkIntDialog.Info = "Effet contraction"; trkIntDialog.ValueInfo = "Déplacement : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 25; trkIntDialog.Value = 15; trkIntDialog.ValueChkB1Text = "Antialiasing"; trkIntDialog.DisplayChkB1 = true; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.TimeWarp(curImg.Image, (byte)trkIntDialog.Value, trkIntDialog.ValueChkB1Checked)) { setThumb(); } } enableImgSettings(true); } private void waterTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Déformation : onde"; trkIntDialog.Info = "Effet d'onde"; trkIntDialog.ValueInfo = "Amplitude : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 25; trkIntDialog.Value = 15; trkIntDialog.ValueChkB1Text = "Antialiasing"; trkIntDialog.DisplayChkB1 = true; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Water(curImg.Image, (short)trkIntDialog.Value, trkIntDialog.ValueChkB1Checked)) { setThumb(); } } enableImgSettings(true); } private void pixMosaicTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Pixellisation : mosaïque"; trkIntDialog.Info = "Effet mosaïque"; trkIntDialog.ValueInfo = "Carreaux : "; trkIntDialog.MinimumValue = 1; trkIntDialog.MaximumValue = 30; trkIntDialog.Value = 15; trkIntDialog.ValueChkB1Text = "Contours"; trkIntDialog.DisplayChkB1 = true; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.Pixelate(curImg.Image, (short)trkIntDialog.Value, trkIntDialog.ValueChkB1Checked)) { setThumb(); } } enableImgSettings(true); } private void sepiaTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); Color color = Color.FromArgb(0, 0, 0, 0); hslDi.SelectedColor = color; if (hslDi.ShowDialog() == DialogResult.OK) { color = hslDi.SelectedColor; if (BitmapFilter.sepia(curImg.Image, color.R / 2, color.G / 2, color.B / 2)) if (BitmapFilter.GaussianBlur(curImg.Image, 4)) { setThumb(); } } enableImgSettings(true); } private void s2ToolStripMenuItem_Click(object sender, EventArgs e) { enableImgSettings(false); trkIntDialog.Text = "Artistique : sépia"; trkIntDialog.Info = "Effet sépia"; trkIntDialog.ValueInfo = "Rouge : "; trkIntDialog.MinimumValue = 0; trkIntDialog.MaximumValue = 255; trkIntDialog.Value = 0; trkIntDialog.ValueChkB1Text = "V"; trkIntDialog.ValueChkB2Text = "R"; trkIntDialog.ValueChkB3Text = "B"; trkIntDialog.DisplayChkB1 = true; trkIntDialog.DisplayChkB2 = true; trkIntDialog.DisplayChkB3 = true; int r, v, b; v = (trkIntDialog.ValueChkB1Checked) ? trkIntDialog.Value : 0; r = (trkIntDialog.ValueChkB2Checked) ? trkIntDialog.Value : 0; b = (trkIntDialog.ValueChkB3Checked) ? trkIntDialog.Value : 0; if (trkIntDialog.ShowDialog(this) == DialogResult.OK) { if (BitmapFilter.sepia(curImg.Image, r, v, b)) { if (BitmapFilter.GaussianBlur(curImg.Image, 4)) setThumb(); } } enableImgSettings(true); } private void colorAvgLumTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); Color color = Color.FromArgb(0, 0, 0); if (hslDi.ShowDialog() == DialogResult.OK) { color = hslDi.SelectedColor; if (BitmapFilter.ColorAvgLum(curImg.Image, color.R / 2, color.G / 2, color.B / 2)) setThumb(); } enableImgSettings(true); } private void colorFastTsMi_Click(object sender, EventArgs e) { enableImgSettings(false); Color color = Color.FromArgb(0, 0, 0); if (hslDi.ShowDialog() == DialogResult.OK) { color = hslDi.SelectedColor; if (BitmapFilter.colorFast(curImg.Image, color.R / 2, color.G / 2, color.B / 2)) setThumb(); } enableImgSettings(true); } #endregion private void aboutPhotoBrolTsMi_Click(object sender, EventArgs e) { } private void openTSMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK == openFileDialog.ShowDialog()) { if (ImageHelper.isImg(openFileDialog.FileName)) { ToolStripMenuItem tsmi = new ToolStripMenuItem(Path.GetFileNameWithoutExtension(openFileDialog.FileName)); if (!mruTsSB.DropDownItems.Contains(tsmi)) { mruTsSB.DropDownItems.Add(tsmi); tsmi.ToolTipText = openFileDialog.FileName; tsmi.Image = iconList1.getImage(openFileDialog.FileName); } ImageLocation = openFileDialog.FileName; saveFileDialog.InitialDirectory = Path.GetDirectoryName(openFileDialog.FileName); } else { if (MessageBox.Show( this, "Les fichiers {0} ne sont pas pris en charge par PhotoBrol", "Erreur de chargement", MessageBoxButtons.RetryCancel, MessageBoxIcon.Stop ) == DialogResult.Retry) { openTSMenuItem_Click(sender, e); } } } } private void openMruTsMi_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; if (tsmi != null) { ImageLocation = tsmi.ToolTipText; } } private void reloadImgTsMi_Click(object sender, EventArgs e) { ImageLocation = img.FullPath; } private void collapseTabsTSB_Click(object sender, EventArgs e) { splitContainer1.Panel2Collapsed = !splitContainer1.Panel2Collapsed; } private void annulerToolStripMenuItem_Click(object sender, EventArgs e) { undo(); } private void rétablirToolStripMenuItem_Click(object sender, EventArgs e) { redo(); } private void saveTsMi_Click(object sender, EventArgs e) { if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { //String ext = Path.GetExtension(saveFileDialog.FileName).ToUpper(); String ext = validImagesFormats[saveFileDialog.FilterIndex-1].ToString().ToLower(); String outputName = saveFileDialog.FileName; if (!outputName.EndsWith("." + ext)) outputName += "." + ext; img.Image = curImg.Image; switch (ext) { case "jpeg": case "jpg": //sid.InputImage = curImg.Image; sid.setImageToCompress(img); sid.ImagePath = outputName; if (sid.ShowDialog(this) == DialogResult.OK) { //sid.InputImage.Save(outputName, ImageFormat.Jpeg); sid.saveImageCompressed(); } break; /*case "bmp": curImg.Image.Save(outputName, ImageFormat.Bmp); break;*/ default: /*MessageBox.Show( this, String.Format("Format d'image non supporté : {0}",ext), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Stop );*/ curImg.Image.Save(outputName, validImagesFormats[saveFileDialog.FilterIndex - 1]); break; } } } private void mruToolStripMenuItem_Click(object sender, EventArgs e) { } /* private void button1_Click(object sender, EventArgs e) { if(curImg.Image!=null) setBrolChart(Imager2.ImagerBitmap.getGreyscaleHistogram(curImg.Image)); } public void setBrolChart(Stat stat) { Color[] colors = new Color[stat.Values.Length]; Color color; float[] displacements = new float[stat.Values.Length]; chartCtl.Values = stat.Values; chartCtl.Texts = stat.Texts; chartCtl.ToolTips = stat.Labels; for (int i = 0; i < stat.Values.Length; i++) { color = BrolColor.getBrolColor(i).BackColor; colors[i] = color; displacements[i] = 0F; } chartCtl.Colors = colors; chartCtl.SliceRelativeDisplacements = displacements; }*/ private void setLastAction(ToolStripMenuItem tsMi, EventHandler e) { int index = toolStrip1.Items.IndexOf(lastActionTSB); if (tsMi.Image != null) { lastActionTSB.Image = tsMi.Image; } lastActionTSB.Click += e; toolStrip1.Items.Insert(index, lastActionTSB); lastActionTSB.Visible = true; lastActionTsMi = tsMi; filterTsMi.DropDownItems.Insert(0,lastActionTsMi); lastActionTsMi.Visible = true; lastActionTsS.Visible = true; } private void showColorsTsMi_Click(object sender, EventArgs e) { form.Show(this); } } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1734910447 23/12/2024 00:34:07 |
| _ | histogram | 0 octets | 1541007196 31/10/2018 18:33:16 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-photobrol-source-rf-view/controls/ImageEditorUserControl.cs.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.