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 // Jordi Mas i Hernandez (jordi@ximian.com)
9 // Sebastien Pouliot <sebastien@ximian.com>
11 // (C) 2002 Ximian, Inc. http://www.ximian.com
12 // Copyright (C) 2004,2006,2007 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.Runtime.InteropServices;
35 using System.Collections;
38 namespace System.Drawing.Imaging {
43 public sealed class ImageCodecInfo {
45 private string codecName;
46 private string dllName;
47 private string filenameExtension;
48 private ImageCodecFlags flags;
49 private string formatDescription;
50 private Guid formatID;
51 private string mimeType;
52 private byte[][] signatureMasks;
53 private byte[][] signaturePatterns;
56 internal ImageCodecInfo()
61 public static ImageCodecInfo[] GetImageDecoders()
63 int decoderNums, arraySize, decoder_size;
64 IntPtr decoders, decoder_ptr;
65 ImageCodecInfo[] result;
66 GdipImageCodecInfo gdipdecoder = new GdipImageCodecInfo();
69 status = GDIPlus.GdipGetImageDecodersSize (out decoderNums, out arraySize);
70 GDIPlus.CheckStatus (status);
72 result = new ImageCodecInfo [decoderNums];
77 /* Get decoders list*/
78 decoders = Marshal.AllocHGlobal (arraySize);
80 status = GDIPlus.GdipGetImageDecoders (decoderNums, arraySize, decoders);
81 GDIPlus.CheckStatus (status);
83 decoder_size = Marshal.SizeOf (gdipdecoder);
84 decoder_ptr = decoders;
86 for (int i = 0; i < decoderNums; i++, decoder_ptr = new IntPtr (decoder_ptr.ToInt64 () + decoder_size)) {
87 gdipdecoder = (GdipImageCodecInfo) Marshal.PtrToStructure (decoder_ptr, typeof (GdipImageCodecInfo));
88 result[i] = new ImageCodecInfo ();
89 GdipImageCodecInfo.MarshalTo (gdipdecoder, result[i]);
93 Marshal.FreeHGlobal (decoders);
99 public static ImageCodecInfo[] GetImageEncoders()
101 int encoderNums, arraySize, encoder_size;
102 IntPtr encoders, encoder_ptr;
103 ImageCodecInfo[] result;
104 GdipImageCodecInfo gdipencoder = new GdipImageCodecInfo();
107 status = GDIPlus.GdipGetImageEncodersSize (out encoderNums, out arraySize);
108 GDIPlus.CheckStatus (status);
110 result = new ImageCodecInfo [encoderNums];
112 if (encoderNums == 0)
115 /* Get encoders list*/
116 encoders = Marshal.AllocHGlobal (arraySize);
118 status = GDIPlus.GdipGetImageEncoders (encoderNums, arraySize, encoders);
119 GDIPlus.CheckStatus (status);
121 encoder_size = Marshal.SizeOf (gdipencoder);
122 encoder_ptr = encoders;
124 for (int i = 0; i < encoderNums; i++, encoder_ptr = new IntPtr (encoder_ptr.ToInt64 () + encoder_size)) {
125 gdipencoder = (GdipImageCodecInfo) Marshal.PtrToStructure (encoder_ptr, typeof (GdipImageCodecInfo));
126 result[i] = new ImageCodecInfo ();
127 GdipImageCodecInfo.MarshalTo (gdipencoder, result[i]);
131 Marshal.FreeHGlobal (encoders);
140 get { return clsid; }
141 set { clsid = value; }
145 public string CodecName
147 get { return codecName; }
148 set { codecName = value; }
152 public string DllName
154 get { return dllName; }
155 set { dllName = value; }
159 public string FilenameExtension
161 get { return filenameExtension; }
162 set { filenameExtension = value; }
166 public ImageCodecFlags Flags
168 get { return flags; }
169 set { flags = value; }
172 public string FormatDescription
174 get { return formatDescription; }
175 set { formatDescription = value; }
180 get { return formatID; }
181 set { formatID = value; }
185 public string MimeType
187 get { return mimeType; }
188 set { mimeType = value; }
192 [CLSCompliant(false)]
193 public byte[][] SignatureMasks
195 get { return signatureMasks; }
196 set { signatureMasks = value; }
199 [CLSCompliant(false)]
200 public byte[][] SignaturePatterns
202 get { return signaturePatterns; }
203 set { signaturePatterns = value; }
208 get { return version; }
209 set { version = value; }