2 // System.Drawing.Imaging.ImageCodecInfo.cs
5 // Everaldo Canuto (everaldo.canuto@bol.com.br)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 // Dennis Hayes (dennish@raytek.com)
8 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
9 // Dennis Hayes (dennish@raytek.com)
10 // Jordi Mas i Hernandez (jordi@ximian.com)
12 // (C) 2002 Ximian, Inc. http://www.ximian.com
13 // Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
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:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
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.
35 using System.Runtime.InteropServices;
36 using System.Collections;
39 namespace System.Drawing.Imaging {
44 public sealed class ImageCodecInfo {
46 private string codecName;
47 private string dllName;
48 private string filenameExtension;
49 private ImageCodecFlags flags;
50 private string formatDescription;
51 private Guid formatID;
52 private string mimeType;
53 private byte[][] signatureMasks;
54 private byte[][] signaturePatterns;
57 internal ImageCodecInfo()
63 public static ImageCodecInfo[] GetImageDecoders()
65 int decoderNums, arraySize, decoder_size;
66 IntPtr decoders, decoder_ptr;
67 ImageCodecInfo[] result;
68 GdipImageCodecInfo gdipdecoder = new GdipImageCodecInfo();
71 status = GDIPlus.GdipGetImageDecodersSize (out decoderNums, out arraySize);
72 GDIPlus.CheckStatus (status);
74 result = new ImageCodecInfo [decoderNums];
79 /* Get decoders list*/
80 decoders = Marshal.AllocHGlobal (arraySize);
82 status = GDIPlus.GdipGetImageDecoders (decoderNums, arraySize, decoders);
83 GDIPlus.CheckStatus (status);
85 decoder_size = Marshal.SizeOf (gdipdecoder);
86 decoder_ptr = decoders;
88 for (int i = 0; i < decoderNums; i++, decoder_ptr = new IntPtr (decoder_ptr.ToInt64 () + decoder_size)) {
89 gdipdecoder = (GdipImageCodecInfo) Marshal.PtrToStructure (decoder_ptr, typeof (GdipImageCodecInfo));
90 result[i] = new ImageCodecInfo ();
91 GdipImageCodecInfo.MarshalTo (gdipdecoder, result[i]);
95 Marshal.FreeHGlobal (decoders);
101 public static ImageCodecInfo[] GetImageEncoders()
103 int encoderNums, arraySize, encoder_size;
104 IntPtr encoders, encoder_ptr;
105 ImageCodecInfo[] result;
106 GdipImageCodecInfo gdipencoder = new GdipImageCodecInfo();
109 status = GDIPlus.GdipGetImageEncodersSize (out encoderNums, out arraySize);
110 GDIPlus.CheckStatus (status);
112 result = new ImageCodecInfo [encoderNums];
114 if (encoderNums == 0)
117 /* Get encoders list*/
118 encoders = Marshal.AllocHGlobal (arraySize);
120 status = GDIPlus.GdipGetImageEncoders (encoderNums, arraySize, encoders);
121 GDIPlus.CheckStatus (status);
123 encoder_size = Marshal.SizeOf (gdipencoder);
124 encoder_ptr = encoders;
126 for (int i = 0; i < encoderNums; i++, encoder_ptr = new IntPtr (encoder_ptr.ToInt64 () + encoder_size)) {
127 gdipencoder = (GdipImageCodecInfo) Marshal.PtrToStructure (encoder_ptr, typeof (GdipImageCodecInfo));
128 result[i] = new ImageCodecInfo ();
129 GdipImageCodecInfo.MarshalTo (gdipencoder, result[i]);
133 Marshal.FreeHGlobal (encoders);
142 get { return clsid; }
143 set { clsid = value; }
147 public string CodecName
149 get { return codecName; }
150 set { codecName = value; }
154 public string DllName
156 get { return dllName; }
157 set { dllName = value; }
161 public string FilenameExtension
163 get { return filenameExtension; }
164 set { filenameExtension = value; }
168 public ImageCodecFlags Flags
170 get { return flags; }
171 set { flags = value; }
174 public string FormatDescription
176 get { return formatDescription; }
177 set { formatDescription = value; }
182 get { return formatID; }
183 set { formatID = value; }
187 public string MimeType
189 get { return mimeType; }
190 set { mimeType = value; }
194 [CLSCompliant(false)]
195 public byte[][] SignatureMasks
197 get { return signatureMasks; }
198 set { signatureMasks = value; }
202 [CLSCompliant(false)]
203 public byte[][] SignaturePatterns
205 get { return signaturePatterns; }
206 set { signaturePatterns = value; }
211 get { return version; }
212 set { version = value; }