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