2 // System.Drawing.gdipStructs.cs
5 // Alexandre Pigolkine (pigolkine@gmx.de)
6 // Jordi Mas (jordi@ximian.com)
8 // Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Drawing.Imaging;
31 using System.Runtime.InteropServices;
33 namespace System.Drawing
35 [StructLayout(LayoutKind.Sequential)]
36 internal struct GdiplusStartupInput
38 // internalted to silent compiler
39 internal uint GdiplusVersion;
40 internal IntPtr DebugEventCallback;
41 internal int SuppressBackgroundThread;
42 internal int SuppressExternalCodecs;
44 internal static GdiplusStartupInput MakeGdiplusStartupInput ()
46 GdiplusStartupInput result = new GdiplusStartupInput ();
47 result.GdiplusVersion = 1;
48 result.DebugEventCallback = IntPtr.Zero;
49 result.SuppressBackgroundThread = 0;
50 result.SuppressExternalCodecs = 0;
55 [StructLayout(LayoutKind.Sequential)]
56 internal struct GdiplusStartupOutput
58 internal IntPtr NotificationHook;
59 internal IntPtr NotificationUnhook;
61 internal static GdiplusStartupOutput MakeGdiplusStartupOutput ()
63 GdiplusStartupOutput result = new GdiplusStartupOutput ();
64 result.NotificationHook = result.NotificationUnhook = IntPtr.Zero;
70 [StructLayout(LayoutKind.Sequential)]
71 internal struct GdiColorPalette
73 internal int Flags; // Palette flags
74 internal int Count; // Number of color entries
77 [StructLayout(LayoutKind.Sequential)]
78 internal struct GdiColorMap
84 [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
85 internal struct LOGFONT
87 internal int lfHeight;
88 internal uint lfWidth;
89 internal uint lfEscapement;
90 internal uint lfOrientation;
91 internal uint lfWeight;
92 internal byte lfItalic;
93 internal byte lfUnderline;
94 internal byte lfStrikeOut;
95 internal byte lfCharSet;
96 internal byte lfOutPrecision;
97 internal byte lfClipPrecision;
98 internal byte lfQuality;
99 internal byte lfPitchAndFamily;
100 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
101 internal string lfFaceName;
104 [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
105 internal struct GdipImageCodecInfo /*Size 76 bytes*/
108 internal Guid FormatID;
109 internal IntPtr CodecName;
110 internal IntPtr DllName;
111 internal IntPtr FormatDescription;
112 internal IntPtr FilenameExtension;
113 internal IntPtr MimeType;
114 internal ImageCodecFlags Flags;
115 internal int Version;
116 internal int SigCount;
117 internal int SigSize;
121 internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
123 codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);
124 codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
125 codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
126 codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
127 codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
128 codec.Clsid = gdipcodec.Clsid;
129 codec.FormatID = gdipcodec.FormatID;
130 codec.Flags = gdipcodec.Flags;
131 codec.Version = gdipcodec.Version;
132 codec.SignatureMasks = new byte [gdipcodec.SigCount][];
133 codec.SignaturePatterns = new byte [gdipcodec.SigCount][];
134 IntPtr p = gdipcodec.SigPattern;
135 IntPtr m = gdipcodec.SigMask;
136 for (int i=0; i < gdipcodec.SigCount; i++) {
137 codec.SignatureMasks[i] = new byte [gdipcodec.SigSize];
138 Marshal.Copy (m, codec.SignatureMasks[i], 0, gdipcodec.SigSize);
139 m = new IntPtr (m.ToInt64 () + gdipcodec.SigSize);
140 codec.SignaturePatterns[i] = new byte [gdipcodec.SigSize];
141 Marshal.Copy (p, codec.SignaturePatterns[i], 0, gdipcodec.SigSize);
142 p = new IntPtr (p.ToInt64 () + gdipcodec.SigSize);
147 [StructLayout(LayoutKind.Sequential)]
148 internal struct GdipEncoderParameter {
150 internal uint numberOfValues;
151 internal EncoderParameterValueType type;
152 internal IntPtr value;
155 [StructLayout(LayoutKind.Sequential)]
156 internal struct GdipPropertyItem
161 internal IntPtr value;
163 internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
165 prop.Id = gdipProp.id;
166 prop.Len = gdipProp.len;
167 prop.Type = gdipProp.type;
168 prop.Value = new byte [gdipProp.len];
169 Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
173 [StructLayout(LayoutKind.Sequential)]
174 internal struct IconInfo
179 public IntPtr hbmMask;
180 public IntPtr hbmColor;
183 get { return (fIcon == 1); }
184 set { fIcon = (value) ? 1 : 0; }
188 [StructLayout(LayoutKind.Sequential)]
189 internal struct XColor
192 public ushort red, green, blue;
197 [StructLayout(LayoutKind.Sequential)]
198 internal struct XVisualInfo
200 internal IntPtr visual;
201 internal int visualid;
205 internal uint red_mask;
206 internal uint green_mask;
207 internal uint blue_mask;
208 internal int colormap_size;
209 internal int bits_per_rgb;
212 internal enum GetSysColorIndex {
214 COLOR_BACKGROUND = 1,
215 COLOR_ACTIVECAPTION = 2,
216 COLOR_INACTIVECAPTION = 3,
219 COLOR_WINDOWFRAME = 6,
221 COLOR_WINDOWTEXT = 8,
222 COLOR_CAPTIONTEXT = 9,
223 COLOR_ACTIVEBORDER = 10,
224 COLOR_INACTIVEBORDER = 11,
225 COLOR_APPWORKSPACE = 12,
226 COLOR_HIGHLIGHT = 13,
227 COLOR_HIGHLIGHTTEXT = 14,
229 COLOR_BTNSHADOW = 16,
232 COLOR_INACTIVECAPTIONTEXT = 19,
233 COLOR_BTNHIGHLIGHT = 20,
234 COLOR_3DDKSHADOW = 21,
240 COLOR_GRADIENTACTIVECAPTION = 27,
241 COLOR_GRADIENTINACTIVECAPTION = 28,
242 COLOR_MENUHIGHLIGHT = 29,
248 COLOR_3DHIGHLIGHT = 20,
249 COLOR_3DHILIGHT = 20,
250 COLOR_BTNHILIGHT = 20,
252 COLOR_MAXVALUE = 30,/* Maximum value */