ImageFormat.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // System.Drawing.Imaging.ImageFormat.cs
  3. //
  4. // Authors:
  5. // Everaldo Canuto ([email protected])
  6. // Andreas Nahr ([email protected])
  7. // Dennis Hayes ([email protected])
  8. // Jordi Mas i Hernandez ([email protected])
  9. //
  10. // (C) 2002-4 Ximian, Inc. http://www.ximian.com
  11. //
  12. //
  13. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining
  16. // a copy of this software and associated documentation files (the
  17. // "Software"), to deal in the Software without restriction, including
  18. // without limitation the rights to use, copy, modify, merge, publish,
  19. // distribute, sublicense, and/or sell copies of the Software, and to
  20. // permit persons to whom the Software is furnished to do so, subject to
  21. // the following conditions:
  22. //
  23. // The above copyright notice and this permission notice shall be
  24. // included in all copies or substantial portions of the Software.
  25. //
  26. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  30. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  31. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  32. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. //
  34. using System;
  35. using System.ComponentModel;
  36. namespace System.Drawing.Imaging {
  37. [TypeConverter (typeof (ImageFormatConverter))]
  38. public sealed class ImageFormat
  39. {
  40. private Guid guid;
  41. private static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
  42. private static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
  43. private static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
  44. private static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
  45. private static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
  46. private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
  47. private static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
  48. private static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
  49. private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
  50. private static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
  51. // constructors
  52. public ImageFormat (Guid guid)
  53. {
  54. this.guid = guid;
  55. }
  56. // methods
  57. public override bool Equals(object o) {
  58. if (o is ImageFormat)
  59. if ( ((ImageFormat)o).Guid.Equals(this.Guid))
  60. return true;
  61. return false;
  62. }
  63. public override int GetHashCode()
  64. {
  65. return guid.GetHashCode();
  66. }
  67. public override string ToString()
  68. {
  69. if (this.Equals (Bmp))
  70. return "Bmp";
  71. if (this.Equals (Emf))
  72. return "Emf";
  73. if (this.Equals (Exif))
  74. return "Exif";
  75. if (this.Equals (Gif))
  76. return "Gif";
  77. if (this.Equals (Tiff))
  78. return "Tiff";
  79. if (this.Equals (Png))
  80. return "Png";
  81. if (this.Equals (MemoryBmp))
  82. return "MemoryBmp";
  83. if (this.Equals (Icon))
  84. return "Icon";
  85. if (this.Equals (Jpeg))
  86. return "Jpeg";
  87. if (this.Equals (Wmf))
  88. return "Wmf";
  89. // Default
  90. return ("[ImageFormat: " + Guid.ToString () + "]");
  91. }
  92. // properties
  93. public Guid Guid
  94. {
  95. get { return guid; }
  96. }
  97. public static ImageFormat Bmp
  98. {
  99. get { return BmpImageFormat; }
  100. }
  101. public static ImageFormat Emf
  102. {
  103. get { return EmfImageFormat; }
  104. }
  105. public static ImageFormat Exif
  106. {
  107. get { return ExifImageFormat; }
  108. }
  109. public static ImageFormat Gif
  110. {
  111. get { return GifImageFormat; }
  112. }
  113. public static ImageFormat Icon
  114. {
  115. get { return IconImageFormat; }
  116. }
  117. public static ImageFormat Jpeg
  118. {
  119. get { return JpegImageFormat; }
  120. }
  121. public static ImageFormat MemoryBmp
  122. {
  123. get { return MemoryBmpImageFormat; }
  124. }
  125. public static ImageFormat Png
  126. {
  127. get { return PngImageFormat; }
  128. }
  129. public static ImageFormat Tiff
  130. {
  131. get { return TiffImageFormat; }
  132. }
  133. public static ImageFormat Wmf
  134. {
  135. get { return WmfImageFormat; }
  136. }
  137. }
  138. }