2 // System.Drawing.Imaging.ImageFormat.cs
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 // Sebastien Pouliot <sebastien@ximian.com>
11 // (C) 2002-4 Ximian, Inc. http://www.ximian.com
12 // Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.ComponentModel;
36 namespace System.Drawing.Imaging {
38 [TypeConverter (typeof (ImageFormatConverter))]
39 public sealed class ImageFormat {
44 private const string BmpGuid = "b96b3cab-0728-11d3-9d7b-0000f81ef32e";
45 private const string EmfGuid = "b96b3cac-0728-11d3-9d7b-0000f81ef32e";
46 private const string ExifGuid = "b96b3cb2-0728-11d3-9d7b-0000f81ef32e";
47 private const string GifGuid = "b96b3cb0-0728-11d3-9d7b-0000f81ef32e";
48 private const string TiffGuid = "b96b3cb1-0728-11d3-9d7b-0000f81ef32e";
49 private const string PngGuid = "b96b3caf-0728-11d3-9d7b-0000f81ef32e";
50 private const string MemoryBmpGuid = "b96b3caa-0728-11d3-9d7b-0000f81ef32e";
51 private const string IconGuid = "b96b3cb5-0728-11d3-9d7b-0000f81ef32e";
52 private const string JpegGuid = "b96b3cae-0728-11d3-9d7b-0000f81ef32e";
53 private const string WmfGuid = "b96b3cad-0728-11d3-9d7b-0000f81ef32e";
56 // http://msdn.microsoft.com/library/en-us/dnaskdr/html/askgui06032003.asp?frame=true
57 private static object locker = new object ();
59 private static ImageFormat BmpImageFormat;
60 private static ImageFormat EmfImageFormat;
61 private static ImageFormat ExifImageFormat;
62 private static ImageFormat GifImageFormat;
63 private static ImageFormat TiffImageFormat;
64 private static ImageFormat PngImageFormat;
65 private static ImageFormat MemoryBmpImageFormat;
66 private static ImageFormat IconImageFormat;
67 private static ImageFormat JpegImageFormat;
68 private static ImageFormat WmfImageFormat;
72 public ImageFormat (Guid guid)
78 private ImageFormat (string name, string guid)
81 this.guid = new Guid (guid);
86 public override bool Equals (object o)
88 ImageFormat f = (o as ImageFormat);
92 return f.Guid.Equals (guid);
96 public override int GetHashCode ()
98 return guid.GetHashCode ();
102 public override string ToString ()
107 return ("[ImageFormat: " + guid.ToString () + "]");
116 public static ImageFormat Bmp {
119 if (BmpImageFormat == null)
120 BmpImageFormat = new ImageFormat ("Bmp", BmpGuid);
121 return BmpImageFormat;
126 public static ImageFormat Emf {
129 if (EmfImageFormat == null)
130 EmfImageFormat = new ImageFormat ("Emf", EmfGuid);
131 return EmfImageFormat;
137 public static ImageFormat Exif {
140 if (ExifImageFormat == null)
141 ExifImageFormat = new ImageFormat ("Exif", ExifGuid);
142 return ExifImageFormat;
148 public static ImageFormat Gif {
151 if (GifImageFormat == null)
152 GifImageFormat = new ImageFormat ("Gif", GifGuid);
153 return GifImageFormat;
159 public static ImageFormat Icon {
162 if (IconImageFormat == null)
163 IconImageFormat = new ImageFormat ("Icon", IconGuid);
164 return IconImageFormat;
170 public static ImageFormat Jpeg {
173 if (JpegImageFormat == null)
174 JpegImageFormat = new ImageFormat ("Jpeg", JpegGuid);
175 return JpegImageFormat;
181 public static ImageFormat MemoryBmp {
184 if (MemoryBmpImageFormat == null)
185 MemoryBmpImageFormat = new ImageFormat ("MemoryBMP", MemoryBmpGuid);
186 return MemoryBmpImageFormat;
192 public static ImageFormat Png {
195 if (PngImageFormat == null)
196 PngImageFormat = new ImageFormat ("Png", PngGuid);
197 return PngImageFormat;
203 public static ImageFormat Tiff {
206 if (TiffImageFormat == null)
207 TiffImageFormat = new ImageFormat ("Tiff", TiffGuid);
208 return TiffImageFormat;
214 public static ImageFormat Wmf {
217 if (WmfImageFormat == null)
218 WmfImageFormat = new ImageFormat ("Wmf", WmfGuid);
219 return WmfImageFormat;