BrolImage.cs

Description du code

BrolImage.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. using System.IO;
  5.  
  6. namespace be.gaudry.model.drawing
  7. {
  8. public class BrolImage : ICloneable
  9. {
  10.  
  11. #region constructor and declarations
  12.  
  13. private Bitmap image;
  14. private FileInfo fileInfo;
  15.  
  16. public BrolImage(){}
  17.  
  18. public BrolImage(String fileName)
  19. {
  20. init(fileName);
  21. }
  22.  
  23. public BrolImage(Bitmap bitmap)
  24. {
  25. image = bitmap;
  26. }
  27.  
  28. private void init(string fileName)
  29. {
  30. if (fileName == String.Empty)
  31. {
  32. image = null;
  33. fileInfo = null;
  34. }
  35. else
  36. {
  37. image = new Bitmap(fileName);
  38. fileInfo = new FileInfo(fileName);
  39. }
  40. }
  41.  
  42. #endregion
  43.  
  44. #region properties
  45. [
  46. //Category("Appearance"),
  47. Browsable(false)/*,
  48.   DisplayName("Taille"),
  49.   Description("Taille De l'image")*/
  50. ]
  51. public Size Size
  52. {
  53. get { return (image!=null) ? image.Size : new Size(); }
  54. }
  55. [Browsable(true)]
  56. public Bitmap Image
  57. {
  58. get { return image; }
  59. set { this.image = value; }
  60. }
  61. [
  62. Category("Fichier"),
  63. Browsable(false),
  64. DisplayName("Chemin"),
  65. Description("Chemin complet de l'image")
  66. ]
  67. public String FullPath
  68. {
  69. get { return (fileInfo != null)?fileInfo.FullName:""; }
  70. set
  71. {
  72. init(value);
  73. }
  74.  
  75. }
  76. [
  77. Category("Fichier"),
  78. Browsable(true),
  79. DisplayName("Dossier"),
  80. Description("Répertoire qui contient l'image")
  81. ]
  82. public String DirectoryPath
  83. {
  84. get { return (fileInfo != null)?fileInfo.DirectoryName:""; }
  85. }
  86. [
  87. Category("Fichier"),
  88. Browsable(true),
  89. DisplayName("Nom"),
  90. Description("Nom de l'image")
  91. ]
  92. public String Name
  93. {
  94. get { return (fileInfo != null)?fileInfo.Name.Replace(fileInfo.Extension, ""):""; }
  95. }
  96. [
  97. Category("Fichier"),
  98. Browsable(true),
  99. Description("Extension du fichier image")
  100. ]
  101. public String Extension
  102. {
  103. get { return (fileInfo != null)?fileInfo.Extension:""; }
  104. }
  105. [
  106. Category("Fichier"),
  107. Browsable(true),
  108. DisplayName("Modification"),
  109. Description("Date de modification de l'image")
  110. ]
  111. public DateTime ModificationDate
  112. {
  113. get
  114. {
  115. if (fileInfo != null)
  116. {
  117. try
  118. { return fileInfo.LastWriteTime; }
  119. catch (Exception)
  120. { return DateTime.Now; }
  121. }
  122. return DateTime.Now;
  123. }
  124. }
  125. [
  126. Category("Fichier"),
  127. Browsable(true),
  128. DisplayName("Création"),
  129. Description("Date de création de l'image")
  130. ]
  131. public DateTime CreationDate
  132. {
  133. get
  134. {
  135. if (fileInfo != null)
  136. {
  137. try
  138. { return fileInfo.CreationTime; }
  139. catch (Exception)
  140. { return DateTime.Now; }
  141. }
  142. return DateTime.Now;
  143. }
  144. }
  145. [
  146. Category("Fichier"),
  147. Browsable(true),
  148. DisplayName("Taille"),
  149. Description("Taille de l'image")
  150. ]
  151. public String Weight
  152. {
  153. get { return (fileInfo != null) ? Units.getLengthString(fileInfo.Length) : ""; }
  154. }
  155. [
  156. Category("Image"),
  157. Browsable(true),
  158. DisplayName("Hauteur"),
  159. Description("Hauteur de l'image")
  160. ]
  161. public int Height
  162. {
  163. get { return (image!=null)?image.Height:0; }
  164. }
  165. [
  166. Category("Image"),
  167. Browsable(true),
  168. DisplayName("Largeur"),
  169. Description("Largeur de l'image")
  170. ]
  171. public int Width
  172. {
  173. get { return (image!=null)?image.Width:0; }
  174. }
  175. [
  176. Category("Image"),
  177. Browsable(true),
  178. DisplayName("Profondeur"),
  179. Description("Nombre de bits utilisés pour coder la couleur")
  180. ]
  181. public int Deep
  182. {
  183. get
  184. {
  185. if (image == null) return 0;
  186. switch (image.PixelFormat)
  187. {
  188. case System.Drawing.Imaging.PixelFormat.Format24bppRgb: return 24;
  189. case System.Drawing.Imaging.PixelFormat.Format16bppArgb1555: return 16;
  190. case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale: return 16;
  191. case System.Drawing.Imaging.PixelFormat.Format16bppRgb555: return 16;
  192. case System.Drawing.Imaging.PixelFormat.Format16bppRgb565: return 16;
  193. case System.Drawing.Imaging.PixelFormat.Format1bppIndexed: return 1;
  194. case System.Drawing.Imaging.PixelFormat.Format32bppArgb: return 32;
  195. case System.Drawing.Imaging.PixelFormat.Format32bppPArgb: return 32;
  196. case System.Drawing.Imaging.PixelFormat.Format32bppRgb: return 32;
  197. case System.Drawing.Imaging.PixelFormat.Format48bppRgb: return 48;
  198. case System.Drawing.Imaging.PixelFormat.Format4bppIndexed: return 64;
  199. case System.Drawing.Imaging.PixelFormat.Format64bppArgb: return 64;
  200. case System.Drawing.Imaging.PixelFormat.Format64bppPArgb: return 64;
  201. case System.Drawing.Imaging.PixelFormat.Format8bppIndexed: return 8;
  202. default: return 0;
  203. }
  204. }
  205. }
  206. #endregion
  207.  
  208. #region ICloneable Membres
  209.  
  210. public object Clone()
  211. {
  212. return (image != null) ? new BrolImage((Bitmap)(image.Clone())) : new BrolImage();
  213. }
  214.  
  215. #endregion
  216. }
  217. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/drawing/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1714330510 28/04/2024 20:55:10
| _colors0 octets1541007202 31/10/2018 18:33:22
| _chart0 octets1541007202 31/10/2018 18:33:22
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/drawing/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csIconExtractor.cs5.18 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csImageHelper.cs7.19 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csBrolImage.cs6.29 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csDibToImage.cs8.83 Ko31/10/2018 18:33:08-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 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-broldev-source-rf-model/drawing/BrolImage.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.