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
16 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
18 // Permission is hereby granted, free of charge, to any person obtaining
19 // a copy of this software and associated documentation files (the
20 // "Software"), to deal in the Software without restriction, including
21 // without limitation the rights to use, copy, modify, merge, publish,
22 // distribute, sublicense, and/or sell copies of the Software, and to
23 // permit persons to whom the Software is furnished to do so, subject to
24 // the following conditions:
26 // The above copyright notice and this permission notice shall be
27 // included in all copies or substantial portions of the Software.
29 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 using System.Runtime.InteropServices;
40 using System.Collections;
43 namespace System.Drawing.Imaging {
46 public sealed class ImageCodecInfo
49 private string codecName;
50 private string dllName;
51 private string filenameExtension;
52 private ImageCodecFlags flags;
53 private string formatDescription;
54 private Guid formatID;
55 private string mimeType;
56 private byte[][] signatureMasks;
57 private byte[][] signaturePatterns;
60 internal ImageCodecInfo()
66 public static ImageCodecInfo[] GetImageDecoders()
68 int decoderNums, arraySize, decoder_size;
69 IntPtr decoders, decoder_ptr;
70 ImageCodecInfo[] result;
71 GdipImageCodecInfo gdipdecoder = new GdipImageCodecInfo();
74 status = GDIPlus.GdipGetImageDecodersSize (out decoderNums, out arraySize);
75 GDIPlus.CheckStatus (status);
77 result = new ImageCodecInfo [decoderNums];
82 /* Get decoders list*/
83 decoders = Marshal.AllocHGlobal (arraySize);
84 status = GDIPlus.GdipGetImageDecoders (decoderNums, arraySize, decoders);
85 GDIPlus.CheckStatus (status);
87 decoder_size = Marshal.SizeOf (gdipdecoder);
88 decoder_ptr = decoders;
90 for (int i = 0; i < decoderNums; i++, decoder_ptr = new IntPtr (decoder_ptr.ToInt64 () + decoder_size))
92 gdipdecoder = (GdipImageCodecInfo) Marshal.PtrToStructure (decoder_ptr, typeof (GdipImageCodecInfo));
93 result[i] = new ImageCodecInfo ();
94 GdipImageCodecInfo.MarshalTo (gdipdecoder, result[i]);
97 Marshal.FreeHGlobal (decoders);
102 public static ImageCodecInfo[] GetImageEncoders()
104 int encoderNums, arraySize, encoder_size;
105 IntPtr encoders, encoder_ptr;
106 ImageCodecInfo[] result;
107 GdipImageCodecInfo gdipencoder = new GdipImageCodecInfo();
110 status = GDIPlus.GdipGetImageEncodersSize (out encoderNums, out arraySize);
111 GDIPlus.CheckStatus (status);
113 result = new ImageCodecInfo [encoderNums];
115 if (encoderNums == 0)
118 /* Get encoders list*/
119 encoders = Marshal.AllocHGlobal (arraySize);
121 status = GDIPlus.GdipGetImageEncoders (encoderNums, arraySize, encoders);
122 GDIPlus.CheckStatus (status);
124 encoder_size = Marshal.SizeOf (gdipencoder);
125 encoder_ptr = encoders;
127 for (int i = 0; i < encoderNums; i++, encoder_ptr = new IntPtr (encoder_ptr.ToInt64 () + encoder_size))
129 gdipencoder = (GdipImageCodecInfo) Marshal.PtrToStructure (encoder_ptr, typeof (GdipImageCodecInfo));
130 result[i] = new ImageCodecInfo ();
131 GdipImageCodecInfo.MarshalTo (gdipencoder, result[i]);
134 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; }