/[gr2lib]/trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs
ViewVC logotype

Annotation of /trunk/gr2lib/core/typedefs/granny_pixel_layouts.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 189 - (hide annotations) (download)
Sat Jul 24 04:52:20 2010 UTC (9 years, 2 months ago) by william
File size: 28780 byte(s)
Add Custom Pixel Layout: GrannyABGR8888PixelFormat

1 william 187 #define HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS // when defined will disable warnings about missing XML comments for all typedefs (CS1591)
2     using System;
3 william 147 using System.Collections.Generic;
4     using System.Linq;
5     using System.Text;
6     using gr2lib.core.coretypes.implementation;
7     using System.Runtime.InteropServices;
8    
9     namespace gr2lib.core.typedefs
10     {
11    
12 william 187 #if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
13     #pragma warning disable 1591
14     #endif
15    
16     #region public enum granny_pixel_layout
17 william 147 public enum granny_pixel_layout
18     {
19     GrannyRGB555PixelFormat,
20     GrannyRGB565PixelFormat,
21     GrannyRGBA5551PixelFormat,
22     GrannyRGBA4444PixelFormat,
23     GrannyRGB888PixelFormat,
24     GrannyRGBA8888PixelFormat,
25 william 173 GrannyARGB8888PixelFormat,
26     GrannyBGR555PixelFormat,
27     GrannyBGR565PixelFormat,
28     GrannyBGRA5551PixelFormat,
29     GrannyBGRA4444PixelFormat,
30     GrannyBGR888PixelFormat,
31 william 187 GrannyBGRA8888PixelFormat,
32     GrannyABGR8888PixelFormat
33 william 147 }
34 william 187 #endregion
35 william 147
36 william 187 #region public struct granny_pixel_layouts
37 william 147 public struct granny_pixel_layouts
38     {
39 william 187 #region GetPixelLayoutFromEnum(granny_pixel_layout layout_type)
40 william 147 public static Layout GetPixelLayoutFromEnum(granny_pixel_layout layout_type)
41     {
42     switch (layout_type)
43     {
44     case granny_pixel_layout.GrannyBGR555PixelFormat: return granny_pixel_layouts.GrannyBGR555PixelFormat;
45     case granny_pixel_layout.GrannyBGR565PixelFormat: return granny_pixel_layouts.GrannyBGR565PixelFormat;
46     case granny_pixel_layout.GrannyBGR888PixelFormat: return granny_pixel_layouts.GrannyBGR888PixelFormat;
47     case granny_pixel_layout.GrannyBGRA4444PixelFormat: return granny_pixel_layouts.GrannyBGRA4444PixelFormat;
48     case granny_pixel_layout.GrannyBGRA5551PixelFormat: return granny_pixel_layouts.GrannyBGRA5551PixelFormat;
49     case granny_pixel_layout.GrannyBGRA8888PixelFormat: return granny_pixel_layouts.GrannyBGRA8888PixelFormat;
50     case granny_pixel_layout.GrannyRGB555PixelFormat: return granny_pixel_layouts.GrannyRGB555PixelFormat;
51     case granny_pixel_layout.GrannyRGB565PixelFormat: return granny_pixel_layouts.GrannyRGB565PixelFormat;
52     case granny_pixel_layout.GrannyRGB888PixelFormat: return granny_pixel_layouts.GrannyRGB888PixelFormat;
53     case granny_pixel_layout.GrannyRGBA4444PixelFormat: return granny_pixel_layouts.GrannyRGBA4444PixelFormat;
54     case granny_pixel_layout.GrannyRGBA5551PixelFormat: return granny_pixel_layouts.GrannyRGBA5551PixelFormat;
55     case granny_pixel_layout.GrannyRGBA8888PixelFormat: return granny_pixel_layouts.GrannyRGBA8888PixelFormat;
56     case granny_pixel_layout.GrannyARGB8888PixelFormat: return granny_pixel_layouts.GrannyARGB8888PixelFormat;
57     default: return granny_pixel_layouts.GrannyDefaultPixelLayout;
58     }
59     }
60 william 187 #endregion
61 william 147 #region Pixel Layout: GrannyDefaultPixelLayout
62     /// <summary>
63 william 148 /// default pixel layout (GrannyRGBA8888PixelFormat)
64 william 147 /// </summary>
65     public static Layout GrannyDefaultPixelLayout
66     {
67 william 187 #region Get GrannyDefaultPixelLayout
68 william 147 get
69     {
70     return GetPixelLayoutFromEnum(granny_pixel_layout.GrannyRGBA8888PixelFormat);
71     }
72 william 187 #endregion
73 william 147 }
74     #endregion
75     #region Pixel Layout: GrannyRGB555PixelFormat
76     /// <summary>
77     /// 16bpp 5-bit red, 5-bit green, 5-bit blue
78     /// </summary>
79     public static Layout GrannyRGB555PixelFormat
80     {
81 william 148 #region Get GrannyRGB555PixelFormat Layout
82 william 147 get
83     {
84 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
85     if (hdl != IntPtr.Zero)
86     {
87     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB555PixelFormat");
88     if (addr != IntPtr.Zero)
89     {
90 william 152 gr2lib.core.coretypes.native.Layout _native_ptr;
91 william 148 gr2lib.core.coretypes.native.Layout _native;
92     Layout _tmp_layout = new Layout();
93 william 152 _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
94     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
95     _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
96     _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
97     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
98     _tmp_layout.BitsForComponent = _native.BitsForComponent;
99 william 148 return _tmp_layout;
100     }
101     else
102     {
103     return new Layout();
104     }
105     }
106     else
107     {
108     return new Layout();
109     }
110 william 147 }
111 william 148 #endregion
112 william 147 }
113     #endregion
114     #region Pixel Layout: GrannyRGB565PixelFormat
115     /// <summary>
116     /// 16bpp 5-bit red, 6-bit green, 5-bit blue
117     /// </summary>
118     public static Layout GrannyRGB565PixelFormat
119     {
120 william 148 #region Get GrannyRGB565PixelFormat Layout
121 william 147 get
122     {
123 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
124     if (hdl != IntPtr.Zero)
125     {
126     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB565PixelFormat");
127     if (addr != IntPtr.Zero)
128     {
129 william 152 gr2lib.core.coretypes.native.Layout _native_ptr;
130 william 148 gr2lib.core.coretypes.native.Layout _native;
131     Layout _tmp_layout = new Layout();
132 william 152 _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
133     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
134     _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
135     _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
136     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
137     _tmp_layout.BitsForComponent = _native.BitsForComponent;
138 william 148 return _tmp_layout;
139     }
140     else
141     {
142     return new Layout();
143     }
144     }
145     else
146     {
147     return new Layout();
148     }
149 william 147 }
150 william 148 #endregion
151 william 147 }
152     #endregion
153     #region Pixel Layout: GrannyRGBA5551PixelFormat
154     /// <summary>
155     /// 16bpp 5-bit red, 5-bit green, 5-bit blue, 1-bit alpha
156     /// </summary>
157     public static Layout GrannyRGBA5551PixelFormat
158     {
159 william 148 #region Get GrannyRGBA5551PixelFormat Layout
160 william 147 get
161     {
162 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
163     if (hdl != IntPtr.Zero)
164     {
165     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA5551PixelFormat");
166     if (addr != IntPtr.Zero)
167     {
168 william 152 gr2lib.core.coretypes.native.Layout _native_ptr;
169 william 148 gr2lib.core.coretypes.native.Layout _native;
170     Layout _tmp_layout = new Layout();
171 william 152 _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
172     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
173     _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
174     _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
175     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
176     _tmp_layout.BitsForComponent = _native.BitsForComponent;
177 william 148 return _tmp_layout;
178     }
179     else
180     {
181     return new Layout();
182     }
183     }
184     else
185     {
186     return new Layout();
187     }
188 william 147 }
189 william 148 #endregion
190 william 147 }
191     #endregion
192     #region Pixel Layout: GrannyRGBA4444PixelFormat
193     /// <summary>
194     /// 16bpp 4-bit red, 4-bit green, 4-bit blue, 4-bit alpha
195     /// </summary>
196     public static Layout GrannyRGBA4444PixelFormat
197     {
198 william 148 #region Get GrannyRGBA4444PixelFormat Layout
199 william 147 get
200     {
201 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
202     if (hdl != IntPtr.Zero)
203     {
204     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA4444PixelFormat");
205     if (addr != IntPtr.Zero)
206     {
207 william 152 gr2lib.core.coretypes.native.Layout _native_ptr;
208 william 148 gr2lib.core.coretypes.native.Layout _native;
209     Layout _tmp_layout = new Layout();
210 william 152 _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
211     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
212     _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
213     _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
214     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
215     _tmp_layout.BitsForComponent = _native.BitsForComponent;
216 william 148 return _tmp_layout;
217     }
218     else
219     {
220     return new Layout();
221     }
222     }
223     else
224     {
225     return new Layout();
226     }
227 william 147 }
228 william 148 #endregion
229 william 147 }
230     #endregion
231     #region Pixel Layout: GrannyRGB888PixelFormat
232     /// <summary>
233     /// 24bpp 8-bit red, 8-bit green, 8-bit blue
234     /// </summary>
235     public static Layout GrannyRGB888PixelFormat
236     {
237 william 148 #region Get GrannyRGB888PixelFormat Layout
238 william 147 get
239     {
240 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
241     if (hdl != IntPtr.Zero)
242     {
243     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGB888PixelFormat");
244     if (addr != IntPtr.Zero)
245     {
246 william 152 gr2lib.core.coretypes.native.Layout _native_ptr;
247 william 148 gr2lib.core.coretypes.native.Layout _native;
248     Layout _tmp_layout = new Layout();
249 william 152 _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
250     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
251     _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
252     _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
253     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
254     _tmp_layout.BitsForComponent = _native.BitsForComponent;
255 william 148 return _tmp_layout;
256     }
257     else
258     {
259     return new Layout();
260     }
261     }
262     else
263     {
264     return new Layout();
265     }
266 william 147 }
267 william 148 #endregion
268 william 147 }
269     #endregion
270     #region Pixel Layout: GrannyRGBA8888PixelFormat
271     /// <summary>
272     /// 32bpp 8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
273     /// </summary>
274     public static Layout GrannyRGBA8888PixelFormat
275     {
276 william 148 #region Get GrannyRGBA8888PixelFormat Layout
277 william 147 get
278     {
279 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
280     if (hdl != IntPtr.Zero)
281     {
282     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyRGBA8888PixelFormat");
283     if (addr != IntPtr.Zero)
284     {
285     gr2lib.core.coretypes.native.Layout _native_ptr;
286     gr2lib.core.coretypes.native.Layout _native;
287     Layout _tmp_layout = new Layout();
288     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
289     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
290 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
291 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
292     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
293     _tmp_layout.BitsForComponent = _native.BitsForComponent;
294     return _tmp_layout;
295     }
296     else
297     {
298     return new Layout();
299     }
300     }
301     else
302     {
303     return new Layout();
304     }
305 william 147 }
306 william 148 #endregion
307 william 147 }
308     #endregion
309     #region Pixel Layout: GrannyARGB8888PixelFormat
310     /// <summary>
311 william 148 /// 32bpp 8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
312 william 147 /// </summary>
313     public static Layout GrannyARGB8888PixelFormat
314     {
315 william 148 #region Get GrannyARGB8888PixelFormat Layout
316 william 147 get
317     {
318 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
319     if (hdl != IntPtr.Zero)
320     {
321     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyARGB8888PixelFormat");
322     if (addr != IntPtr.Zero)
323     {
324     gr2lib.core.coretypes.native.Layout _native_ptr;
325     gr2lib.core.coretypes.native.Layout _native;
326     Layout _tmp_layout = new Layout();
327     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
328     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
329 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
330 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
331     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
332     _tmp_layout.BitsForComponent = _native.BitsForComponent;
333     return _tmp_layout;
334     }
335     else
336     {
337     return new Layout();
338     }
339     }
340     else
341     {
342     return new Layout();
343     }
344 william 147 }
345 william 148 #endregion
346 william 147 }
347     #endregion
348 william 187
349     #region Pixel Layout: GrannyABGR8888PixelFormat
350     /// <summary>
351     /// 32bpp 8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
352     /// </summary>
353     public static Layout GrannyABGR8888PixelFormat
354     {
355     #region Get GrannyABGR8888PixelFormat Layout
356     get
357     {
358 william 189 Layout _tmp_layout = granny_pixel_layouts.GrannyARGB8888PixelFormat;
359 william 187 unsafe
360     {
361 william 189 GCHandle layoutHandle = GCHandle.Alloc(_tmp_layout.BytesPerPixel, GCHandleType.Pinned);
362     _tmp_layout.NativePointer = layoutHandle.AddrOfPinnedObject();
363     layoutHandle.Free();
364 william 187 }
365     int R = _tmp_layout.ShiftForComponent[1];
366     int B = _tmp_layout.ShiftForComponent[3];
367    
368     // swap R & B
369     _tmp_layout.ShiftForComponent[1] = B;
370     _tmp_layout.ShiftForComponent[3] = R;
371     return _tmp_layout;
372     }
373     #endregion
374     }
375     #endregion
376    
377 william 147 #region Pixel Layout: GrannyBGR555PixelFormat
378     /// <summary>
379 william 148 /// 16bpp 5-bit blue, 5-bit green, 5-bit red
380 william 147 /// </summary>
381     public static Layout GrannyBGR555PixelFormat
382     {
383 william 148 #region Get GrannyBGR555PixelFormat Layout
384 william 147 get
385     {
386 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
387     if (hdl != IntPtr.Zero)
388     {
389     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR555PixelFormat");
390     if (addr != IntPtr.Zero)
391     {
392     gr2lib.core.coretypes.native.Layout _native_ptr;
393     gr2lib.core.coretypes.native.Layout _native;
394     Layout _tmp_layout = new Layout();
395     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
396     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
397 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
398 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
399     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
400     _tmp_layout.BitsForComponent = _native.BitsForComponent;
401     return _tmp_layout;
402     }
403     else
404     {
405     return new Layout();
406     }
407     }
408     else
409     {
410     return new Layout();
411     }
412 william 147 }
413 william 148 #endregion
414 william 147 }
415     #endregion
416     #region Pixel Layout: GrannyBGR565PixelFormat
417     /// <summary>
418 william 148 /// 16bpp 5-bit blue, 6-bit green, 5-bit red
419 william 147 /// </summary>
420     public static Layout GrannyBGR565PixelFormat
421     {
422 william 148 #region Get GrannyBGR565PixelFormat Layout
423 william 147 get
424     {
425 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
426     if (hdl != IntPtr.Zero)
427     {
428     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR565PixelFormat");
429     if (addr != IntPtr.Zero)
430     {
431     gr2lib.core.coretypes.native.Layout _native_ptr;
432     gr2lib.core.coretypes.native.Layout _native;
433     Layout _tmp_layout = new Layout();
434     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
435     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
436 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
437 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
438     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
439     _tmp_layout.BitsForComponent = _native.BitsForComponent;
440     return _tmp_layout;
441     }
442     else
443     {
444     return new Layout();
445     }
446     }
447     else
448     {
449     return new Layout();
450     }
451 william 147 }
452 william 148 #endregion
453 william 147 }
454     #endregion
455     #region Pixel Layout: GrannyBGRA5551PixelFormat
456     /// <summary>
457     /// 16bpp 5-bit blue, 5-bit green, 5-bit red, 1-bit alpha
458     /// </summary>
459     public static Layout GrannyBGRA5551PixelFormat
460     {
461 william 148 #region Get GrannyBGRA5551PixelFormat Layout
462 william 147 get
463     {
464 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
465     if (hdl != IntPtr.Zero)
466     {
467     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA5551PixelFormat");
468     if (addr != IntPtr.Zero)
469     {
470     gr2lib.core.coretypes.native.Layout _native_ptr;
471     gr2lib.core.coretypes.native.Layout _native;
472     Layout _tmp_layout = new Layout();
473     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
474     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
475 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
476 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
477     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
478     _tmp_layout.BitsForComponent = _native.BitsForComponent;
479     return _tmp_layout;
480     }
481     else
482     {
483     return new Layout();
484     }
485     }
486     else
487     {
488     return new Layout();
489     }
490 william 147 }
491 william 148 #endregion
492 william 147 }
493     #endregion
494     #region Pixel Layout: GrannyBGRA4444PixelFormat
495     /// <summary>
496 william 148 /// 16bpp 4-bit blue, 4-bit green, 4-bit red, 4-bit alpha
497 william 147 /// </summary>
498     public static Layout GrannyBGRA4444PixelFormat
499     {
500 william 148 #region Get GrannyBGRA4444PixelFormat Layout
501 william 147 get
502     {
503 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
504     if (hdl != IntPtr.Zero)
505     {
506     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA4444PixelFormat");
507     if (addr != IntPtr.Zero)
508     {
509     gr2lib.core.coretypes.native.Layout _native_ptr;
510     gr2lib.core.coretypes.native.Layout _native;
511     Layout _tmp_layout = new Layout();
512     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
513     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
514 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
515 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
516     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
517     _tmp_layout.BitsForComponent = _native.BitsForComponent;
518     return _tmp_layout;
519     }
520     else
521     {
522     return new Layout();
523     }
524     }
525     else
526     {
527     return new Layout();
528     }
529 william 147 }
530 william 148 #endregion
531 william 147 }
532     #endregion
533     #region Pixel Layout: GrannyBGR888PixelFormat
534     /// <summary>
535     /// 24bpp 8-bit blue, 8-bit green, 8-bit red
536     /// </summary>
537     public static Layout GrannyBGR888PixelFormat
538     {
539 william 148 #region Get GrannyBGR888PixelFormat Layout
540 william 147 get
541     {
542 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
543     if (hdl != IntPtr.Zero)
544     {
545     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGR888PixelFormat");
546     if (addr != IntPtr.Zero)
547     {
548     gr2lib.core.coretypes.native.Layout _native_ptr;
549     gr2lib.core.coretypes.native.Layout _native;
550     Layout _tmp_layout = new Layout();
551     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
552     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
553 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
554 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
555     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
556     _tmp_layout.BitsForComponent = _native.BitsForComponent;
557     return _tmp_layout;
558     }
559     else
560     {
561     return new Layout();
562     }
563     }
564     else
565     {
566     return new Layout();
567     }
568 william 147 }
569 william 148 #endregion
570 william 147 }
571     #endregion
572     #region Pixel Layout: GrannyBGRA8888PixelFormat
573     /// <summary>
574     /// 32bpp 8-bit blue, 8-bit green, 8-bit red, 8-bit alpha
575     /// </summary>
576     public static Layout GrannyBGRA8888PixelFormat
577     {
578 william 148 #region Get GrannyBGRA8888PixelFormat Layout
579 william 147 get
580     {
581 william 148 IntPtr hdl = coreapi.LoadLibrary("granny2.dll");
582     if (hdl != IntPtr.Zero)
583     {
584     IntPtr addr = coreapi.GetProcAddress(hdl, "GrannyBGRA8888PixelFormat");
585     if (addr != IntPtr.Zero)
586     {
587     gr2lib.core.coretypes.native.Layout _native_ptr;
588     gr2lib.core.coretypes.native.Layout _native;
589     Layout _tmp_layout = new Layout();
590     _native_ptr = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure(addr, typeof(gr2lib.core.coretypes.native.Layout));
591     _native = (gr2lib.core.coretypes.native.Layout)Marshal.PtrToStructure((IntPtr)_native_ptr.BytesPerPixel, typeof(gr2lib.core.coretypes.native.Layout));
592 william 152 _tmp_layout.NativePointer = (IntPtr)_native_ptr.BytesPerPixel;
593 william 148 _tmp_layout.BytesPerPixel = _native.BytesPerPixel;
594     _tmp_layout.ShiftForComponent = _native.ShiftForComponent;
595     _tmp_layout.BitsForComponent = _native.BitsForComponent;
596     return _tmp_layout;
597     }
598     else
599     {
600     return new Layout();
601     }
602     }
603     else
604     {
605     return new Layout();
606     }
607 william 147 }
608 william 148 #endregion
609 william 147 }
610     #endregion
611     }
612 william 187 #endregion
613    
614     #if HIDE_MISSING_XML_COMMENTS_FOR_TYPEDEFS
615     #pragma warning restore 1591
616     #endif
617 william 147 }

  ViewVC Help
Powered by ViewVC 1.1.22