ImageFormat.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. using System;
  13. using System.ComponentModel;
  14. namespace System.Drawing.Imaging {
  15. [TypeConverter (typeof (ImageFormatConverter))]
  16. public sealed class ImageFormat
  17. {
  18. private Guid guid;
  19. private static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
  20. private static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
  21. private static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
  22. private static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
  23. private static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
  24. private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
  25. private static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
  26. private static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
  27. private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
  28. private static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
  29. // constructors
  30. public ImageFormat (Guid guid)
  31. {
  32. this.guid = guid;
  33. }
  34. // methods
  35. public override bool Equals(object o) {
  36. if (o is ImageFormat)
  37. if ( ((ImageFormat)o).Guid.Equals(this.Guid))
  38. return true;
  39. return false;
  40. }
  41. public override int GetHashCode()
  42. {
  43. return guid.GetHashCode();
  44. }
  45. public override string ToString()
  46. {
  47. if (Guid.Equals (Bmp.Guid))
  48. return "Bmp";
  49. if (Guid.Equals (Emf.Guid))
  50. return "Emf";
  51. if (Guid.Equals (Gif.Guid))
  52. return "Gif";
  53. if (Guid.Equals (Jpeg.Guid))
  54. return "Jpeg";
  55. if (Guid.Equals (MemoryBmp.Guid))
  56. return "MemoryBmp";
  57. if (Guid.Equals (Png.Guid))
  58. return "Png";
  59. if (Guid.Equals (Tiff.Guid))
  60. return "Tiff";
  61. if (Guid.Equals (Wmf.Guid))
  62. return "Wmf";
  63. // Default
  64. return guid.ToString ();
  65. }
  66. // properties
  67. public Guid Guid
  68. {
  69. get { return guid; }
  70. }
  71. public static ImageFormat Bmp
  72. {
  73. get { return BmpImageFormat; }
  74. }
  75. public static ImageFormat Emf
  76. {
  77. get { return EmfImageFormat; }
  78. }
  79. public static ImageFormat Exif
  80. {
  81. get { return ExifImageFormat; }
  82. }
  83. public static ImageFormat Gif
  84. {
  85. get { return GifImageFormat; }
  86. }
  87. public static ImageFormat Icon
  88. {
  89. get { return IconImageFormat; }
  90. }
  91. public static ImageFormat Jpeg
  92. {
  93. get { return JpegImageFormat; }
  94. }
  95. public static ImageFormat MemoryBmp
  96. {
  97. get { return MemoryBmpImageFormat; }
  98. }
  99. public static ImageFormat Png
  100. {
  101. get { return PngImageFormat; }
  102. }
  103. public static ImageFormat Tiff
  104. {
  105. get { return TiffImageFormat; }
  106. }
  107. public static ImageFormat Wmf
  108. {
  109. get { return WmfImageFormat; }
  110. }
  111. }
  112. }