RGBLHistogramUserControl.cs

Description du code

RGBLHistogramUserControl.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

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using be.gaudry.photobrol.view.controls.histogram;
  9. using be.gaudry.photobrol.model.image;
  10.  
  11. namespace be.gaudry.photobrol.view.controls
  12. {
  13. public partial class RGBLHistogramUserControl : UserControl
  14. {
  15.  
  16. private ImageStatistics stat;
  17. private be.gaudry.model.math.Histogram redMHistogram, greenMHistogram, blueMHistogram;
  18. public RGBLHistogramUserControl()
  19. {
  20. redMHistogram = null;
  21. greenMHistogram = null;
  22. blueMHistogram = null;
  23. InitializeComponent();
  24. }
  25.  
  26. // Gather image statistics
  27. public void GatherStatistics(Bitmap image)
  28. {
  29. // avoid calculation in the case of the same image
  30. /*if (image != null)
  31.   {
  32.   if (currentImageHash == image.GetHashCode())
  33.   return;
  34.   currentImageHash = image.GetHashCode();
  35.   }*/
  36. System.Console.WriteLine("set stats");
  37. redGB.Visible = false;
  38. greenGB.Visible = false;
  39. blueGB.Visible = false;
  40.  
  41. // busy
  42. Capture = true;
  43. Cursor = Cursors.WaitCursor;
  44.  
  45. // get statistics
  46. stat = (image == null) ? null : new ImageStatistics(image);
  47.  
  48. // free
  49. Cursor = Cursors.Arrow;
  50. Capture = false;
  51.  
  52. if (stat != null)
  53. {
  54. redGB.Visible = (!stat.IsGrayscale);
  55. greenGB.Visible = redGB.Visible;
  56. blueGB.Visible = redGB.Visible;
  57. displayHistogram();
  58. }
  59. /*else
  60.   {
  61.   redHistogram.Values = null;
  62.   greenMHistogram = null;
  63.   blueMHistogram = null;
  64.  
  65.   redMeanLabel.Text = String.Empty;
  66.   redStdDevLabel.Text = String.Empty;
  67.   redMedianLabel.Text = String.Empty;
  68.   redMinLabel.Text = String.Empty;
  69.   redMaxLabel.Text = String.Empty;
  70.  
  71.   greenMeanLabel.Text = String.Empty;
  72.   greenStdDevLabel.Text = String.Empty;
  73.   greenMedianLabel.Text = String.Empty;
  74.   greenMinLabel.Text = String.Empty;
  75.   greenMaxLabel.Text = String.Empty;
  76.  
  77.   blueMeanLabel.Text = String.Empty;
  78.   blueStdDevLabel.Text = String.Empty;
  79.   blueMedianLabel.Text = String.Empty;
  80.   blueMinLabel.Text = String.Empty;
  81.   blueMaxLabel.Text = String.Empty;
  82.  
  83.   levelLabel.Text = String.Empty;
  84.   countLabel.Text = String.Empty;
  85.   percentileLabel.Text = String.Empty;
  86.   }*/
  87. }
  88.  
  89. private void displayHistogram()
  90. {
  91. if (!stat.IsGrayscale)
  92. {
  93. redGB.Text = "Rouge";
  94. redHistogram.Color = Color.Red;
  95. redMHistogram = stat.Red;
  96. greenMHistogram = stat.Green;
  97. blueMHistogram = stat.Blue;
  98. redGB.Visible = true;
  99. greenGB.Visible = true;
  100. blueGB.Visible = true;
  101. }
  102. else
  103. {
  104. redGB.Text = "Gris";
  105. redHistogram.Color = Color.Gray;
  106. redMHistogram = stat.Gray;
  107. redGB.Visible = true;
  108. }
  109.  
  110. if (redMHistogram != null)
  111. {
  112. redHistogram.Values = redMHistogram.Values;
  113.  
  114. redMeanLabel.Text = redMHistogram.Mean.ToString("F2");
  115. redStdDevLabel.Text = redMHistogram.StdDev.ToString("F2");
  116. redMedianLabel.Text = redMHistogram.Median.ToString();
  117. redMinLabel.Text = redMHistogram.Min.ToString();
  118. redMaxLabel.Text = redMHistogram.Max.ToString();
  119. }
  120. if (greenMHistogram != null)
  121. {
  122. greenHistogram.Values = greenMHistogram.Values;
  123.  
  124. greenMeanLabel.Text = greenMHistogram.Mean.ToString("F2");
  125. greenStdDevLabel.Text = greenMHistogram.StdDev.ToString("F2");
  126. greenMedianLabel.Text = greenMHistogram.Median.ToString();
  127. greenMinLabel.Text = greenMHistogram.Min.ToString();
  128. greenMaxLabel.Text = greenMHistogram.Max.ToString();
  129. }
  130. if (blueMHistogram != null)
  131. {
  132. blueHistogram.Values = blueMHistogram.Values;
  133.  
  134. blueMeanLabel.Text = blueMHistogram.Mean.ToString("F2");
  135. blueStdDevLabel.Text = blueMHistogram.StdDev.ToString("F2");
  136. blueMedianLabel.Text = blueMHistogram.Median.ToString();
  137. blueMinLabel.Text = blueMHistogram.Min.ToString();
  138. blueMaxLabel.Text = blueMHistogram.Max.ToString();
  139. }
  140. }
  141.  
  142. // Cursor position changed over the histogram
  143. private void histogram_PositionChanged(object sender, HistogramEventArgs e)
  144. {
  145. int pos = e.Position;
  146.  
  147. if (pos != -1)
  148. {
  149.  
  150. levelLabel.Text = pos.ToString();
  151. if (pos < redMHistogram.Values.Length) countLabel.Text = redMHistogram.Values[pos].ToString();
  152. percentileLabel.Text = ((float)redMHistogram.Values[pos] * 100 / stat.PixelsCount).ToString("F2");
  153. }
  154. else
  155. {
  156.  
  157. levelLabel.Text = "";
  158. countLabel.Text = "";
  159. percentileLabel.Text = "";
  160. }
  161. }
  162.  
  163. // Selection changed in the histogram
  164. private void histogram_SelectionChanged(object sender, HistogramEventArgs e)
  165. {
  166. int min = e.Min;
  167. int max = e.Max;
  168. int count = 0;
  169.  
  170. levelLabel.Text = min.ToString() + "..." + max.ToString();
  171.  
  172. // count pixels
  173. for (int i = min; i <= max; i++)
  174. {
  175. count += redMHistogram.Values[i];
  176. }
  177. countLabel.Text = count.ToString();
  178. percentileLabel.Text = ((float)count * 100 / stat.PixelsCount).ToString("F2");
  179. }
  180.  
  181. // On "Log" check - switch mode
  182. private void logCheck_CheckedChanged(object sender, System.EventArgs e)
  183. {
  184. redHistogram.LogView = logCheck.Checked;
  185. greenHistogram.LogView = logCheck.Checked;
  186. blueHistogram.LogView = logCheck.Checked;
  187. }
  188.  
  189. private void histogram_MouseEnter(object sender, EventArgs e)
  190. {
  191. //System.Console.WriteLine("sender : " + ((Histogram.Histogram)sender).Name);
  192. colorLbl.BackColor = ((histogram.Histogram)sender).Color;
  193. mouseOverInfoLbl.Visible = false;
  194. }
  195.  
  196. private void histogram_MouseLeave(object sender, EventArgs e)
  197. {
  198. mouseOverInfoLbl.Visible = true;
  199. colorLbl.BackColor = infosGB.BackColor;
  200. }
  201. }
  202. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/photobrol/view/controls/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1718137313 11/06/2024 22:21:53
| _histogram0 octets1541007196 31/10/2018 18:33:16
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/photobrol/view/controls/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csRGBLHistogramUserControl.cs7.13 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csHistogramUserControl.Designer.cs15.78 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csCompressJpegUserControl.Designer.cs13.8 Ko31/10/2018 18:32:51-refusé-
Afficher le fichier .resx|.resxCompressJpegUserControl.resx5.68 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .resx|.resxRGBLHistogramUserControl.resx5.68 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csHistogramUserControl.cs6.31 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .resx|.resxHistogramUserControl.resx5.68 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csCompressJpegUserControl.cs3.77 Ko31/10/2018 18:32:51-refusé-
Afficher le fichier .cs|.csRGBLHistogramUserControl.Designer.cs29.94 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csImageEditorUserControl.cs41.8 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .resx|.resxImageEditorUserControl.resx17.34 Ko31/10/2018 18:32:52-refusé-
Afficher le fichier .cs|.csImageEditorUserControl.Designer.cs126.15 Ko31/10/2018 18:32:52-refusé-

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.

Document créé le 30/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-photobrol-source-rf-view/controls//RGBLHistogramUserControl.cs.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.