/[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 147 - (hide annotations) (download)
Tue Jul 20 06:30:31 2010 UTC (9 years, 2 months ago) by william
File size: 12013 byte(s)
seperate granny pixel layouts into its own .cs file
** add enum for the pixel types
** add static method to get pixel layout from enum value

1 william 147 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using gr2lib.core.coretypes.implementation;
6     using System.Runtime.InteropServices;
7    
8     namespace gr2lib.core.typedefs
9     {
10    
11     public enum granny_pixel_layout
12     {
13     GrannyRGB555PixelFormat,
14     GrannyRGB565PixelFormat,
15     GrannyRGBA5551PixelFormat,
16     GrannyRGBA4444PixelFormat,
17     GrannyRGB888PixelFormat,
18     GrannyRGBA8888PixelFormat,
19     GrannyARGB8888PixelFormat,
20     GrannyBGR555PixelFormat,
21     GrannyBGR565PixelFormat,
22     GrannyBGRA5551PixelFormat,
23     GrannyBGRA4444PixelFormat,
24     GrannyBGR888PixelFormat,
25     GrannyBGRA8888PixelFormat
26     }
27    
28     public struct granny_pixel_layouts
29     {
30    
31     public static Layout GetPixelLayoutFromEnum(granny_pixel_layout layout_type)
32     {
33     switch (layout_type)
34     {
35     case granny_pixel_layout.GrannyBGR555PixelFormat: return granny_pixel_layouts.GrannyBGR555PixelFormat;
36     case granny_pixel_layout.GrannyBGR565PixelFormat: return granny_pixel_layouts.GrannyBGR565PixelFormat;
37     case granny_pixel_layout.GrannyBGR888PixelFormat: return granny_pixel_layouts.GrannyBGR888PixelFormat;
38     case granny_pixel_layout.GrannyBGRA4444PixelFormat: return granny_pixel_layouts.GrannyBGRA4444PixelFormat;
39     case granny_pixel_layout.GrannyBGRA5551PixelFormat: return granny_pixel_layouts.GrannyBGRA5551PixelFormat;
40     case granny_pixel_layout.GrannyBGRA8888PixelFormat: return granny_pixel_layouts.GrannyBGRA8888PixelFormat;
41     case granny_pixel_layout.GrannyRGB555PixelFormat: return granny_pixel_layouts.GrannyRGB555PixelFormat;
42     case granny_pixel_layout.GrannyRGB565PixelFormat: return granny_pixel_layouts.GrannyRGB565PixelFormat;
43     case granny_pixel_layout.GrannyRGB888PixelFormat: return granny_pixel_layouts.GrannyRGB888PixelFormat;
44     case granny_pixel_layout.GrannyRGBA4444PixelFormat: return granny_pixel_layouts.GrannyRGBA4444PixelFormat;
45     case granny_pixel_layout.GrannyRGBA5551PixelFormat: return granny_pixel_layouts.GrannyRGBA5551PixelFormat;
46     case granny_pixel_layout.GrannyRGBA8888PixelFormat: return granny_pixel_layouts.GrannyRGBA8888PixelFormat;
47     case granny_pixel_layout.GrannyARGB8888PixelFormat: return granny_pixel_layouts.GrannyARGB8888PixelFormat;
48     default: return granny_pixel_layouts.GrannyDefaultPixelLayout;
49     }
50     }
51    
52    
53     #region Pixel Layout: GrannyDefaultPixelLayout
54     /// <summary>
55     /// default pixel layout
56     /// </summary>
57     public static Layout GrannyDefaultPixelLayout
58     {
59     get
60     {
61     return GetPixelLayoutFromEnum(granny_pixel_layout.GrannyRGBA8888PixelFormat);
62     }
63     }
64     #endregion
65    
66     #region Pixel Layout: GrannyRGB555PixelFormat
67     /// <summary>
68     /// 16bpp 5-bit red, 5-bit green, 5-bit blue
69     /// </summary>
70     public static Layout GrannyRGB555PixelFormat
71     {
72     get
73     {
74     int bits_per_pixel = 16;
75     int bytes_per_pixel = bits_per_pixel / 8;
76     Layout _layout = new Layout();
77     _layout.BytesPerPixel = bytes_per_pixel;
78     _layout.ShiftForComponent = new int[3] { 0, 5, 10};
79     _layout.BitsForComponent = new int[3] { 5, 5, 5 };
80     return _layout;
81     }
82     }
83     #endregion
84    
85     #region Pixel Layout: GrannyRGB565PixelFormat
86     /// <summary>
87     /// 16bpp 5-bit red, 6-bit green, 5-bit blue
88     /// </summary>
89     public static Layout GrannyRGB565PixelFormat
90     {
91     get
92     {
93     int bits_per_pixel = 16;
94     int bytes_per_pixel = bits_per_pixel / 8;
95     Layout _layout = new Layout();
96     _layout.BytesPerPixel = bytes_per_pixel;
97     _layout.ShiftForComponent = new int[3] { 0, 6, 11 };
98     _layout.BitsForComponent = new int[3] { 5, 6, 5 };
99     return _layout;
100     }
101     }
102     #endregion
103    
104     #region Pixel Layout: GrannyRGBA5551PixelFormat
105     /// <summary>
106     /// 16bpp 5-bit red, 5-bit green, 5-bit blue, 1-bit alpha
107     /// </summary>
108     public static Layout GrannyRGBA5551PixelFormat
109     {
110     get
111     {
112     int bits_per_pixel = 16;
113     int bytes_per_pixel = bits_per_pixel / 8;
114     Layout _layout = new Layout();
115     _layout.BytesPerPixel = bytes_per_pixel;
116     _layout.ShiftForComponent = new int[4] { 0, 5, 10, 1 };
117     _layout.BitsForComponent = new int[4] { 5, 5, 5, 1 };
118     return _layout;
119     }
120     }
121     #endregion
122    
123     #region Pixel Layout: GrannyRGBA4444PixelFormat
124     /// <summary>
125     /// 16bpp 4-bit red, 4-bit green, 4-bit blue, 4-bit alpha
126     /// </summary>
127     public static Layout GrannyRGBA4444PixelFormat
128     {
129     get
130     {
131     int bits_per_pixel = 16;
132     int bytes_per_pixel = bits_per_pixel / 8;
133     Layout _layout = new Layout();
134     _layout.BytesPerPixel = bytes_per_pixel;
135     _layout.ShiftForComponent = new int[4] { 0, 4, 8, 12 };
136     _layout.BitsForComponent = new int[4] { 4, 4, 4, 4 };
137     return _layout;
138     }
139     }
140     #endregion
141    
142     #region Pixel Layout: GrannyRGB888PixelFormat
143     /// <summary>
144     /// 24bpp 8-bit red, 8-bit green, 8-bit blue
145     /// </summary>
146     public static Layout GrannyRGB888PixelFormat
147     {
148     get
149     {
150     int bits_per_pixel = 24;
151     int bytes_per_pixel = bits_per_pixel / 8;
152     Layout _layout = new Layout();
153     _layout.BytesPerPixel = bytes_per_pixel;
154     _layout.ShiftForComponent = new int[3] { 0, 8, 16};
155     _layout.BitsForComponent = new int[3] { 8, 8, 8};
156     return _layout;
157     }
158     }
159     #endregion
160    
161     #region Pixel Layout: GrannyRGBA8888PixelFormat
162     /// <summary>
163     /// 32bpp 8-bit red, 8-bit green, 8-bit blue, 8-bit alpha
164     /// </summary>
165     public static Layout GrannyRGBA8888PixelFormat
166     {
167     get
168     {
169     int bits_per_pixel = 32;
170     int bytes_per_pixel = bits_per_pixel / 8;
171     Layout _layout = new Layout();
172     _layout.BytesPerPixel = bytes_per_pixel;
173    
174     _layout.ShiftForComponent = new int[4] { 0, 8, 16, 24 };
175     _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
176     return _layout;
177    
178     }
179     }
180     #endregion
181    
182     #region Pixel Layout: GrannyARGB8888PixelFormat
183     /// <summary>
184     /// 24bpp 8-bit alpha, 8-bit red, 8-bit green, 8-bit blue
185     /// </summary>
186     public static Layout GrannyARGB8888PixelFormat
187     {
188     get
189     {
190     int bits_per_pixel = 24;
191     int bytes_per_pixel = bits_per_pixel / 8;
192     Layout _layout = new Layout();
193     _layout.BytesPerPixel = bytes_per_pixel;
194     _layout.ShiftForComponent = new int[4] { 24, 0, 8, 16 };
195     _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
196     return _layout;
197     }
198     }
199     #endregion
200    
201     #region Pixel Layout: GrannyBGR555PixelFormat
202     /// <summary>
203     /// 16bpp 5-bit red, 5-bit green, 5-bit blue
204     /// </summary>
205     public static Layout GrannyBGR555PixelFormat
206     {
207     get
208     {
209     int bits_per_pixel = 16;
210     int bytes_per_pixel = bits_per_pixel / 8;
211     Layout _layout = new Layout();
212     _layout.BytesPerPixel = bytes_per_pixel;
213     _layout.ShiftForComponent = new int[3] { 10, 5, 0 };
214     _layout.BitsForComponent = new int[3] { 5, 5, 5 };
215     return _layout;
216     }
217     }
218     #endregion
219    
220    
221     #region Pixel Layout: GrannyBGR565PixelFormat
222     /// <summary>
223     /// 16bpp 5-bit red, 6-bit green, 5-bit blue
224     /// </summary>
225     public static Layout GrannyBGR565PixelFormat
226     {
227     get
228     {
229     int bits_per_pixel = 16;
230     int bytes_per_pixel = bits_per_pixel / 8;
231     Layout _layout = new Layout();
232     _layout.BytesPerPixel = bytes_per_pixel;
233     _layout.ShiftForComponent = new int[3] { 11, 6, 0 };
234     _layout.BitsForComponent = new int[3] { 5, 6, 5 };
235     return _layout;
236     }
237     }
238     #endregion
239    
240     #region Pixel Layout: GrannyBGRA5551PixelFormat
241     /// <summary>
242     /// 16bpp 5-bit blue, 5-bit green, 5-bit red, 1-bit alpha
243     /// </summary>
244     public static Layout GrannyBGRA5551PixelFormat
245     {
246     get
247     {
248     int bits_per_pixel = 16;
249     int bytes_per_pixel = bits_per_pixel / 8;
250     Layout _layout = new Layout();
251     _layout.BytesPerPixel = bytes_per_pixel;
252     _layout.ShiftForComponent = new int[4] { 10, 5, 0, 1 };
253     _layout.BitsForComponent = new int[4] { 5, 5, 5, 1 };
254     return _layout;
255     }
256     }
257     #endregion
258    
259     #region Pixel Layout: GrannyBGRA4444PixelFormat
260     /// <summary>
261     /// 16bpp 4-bit red, 4-bit green, 4-bit blue, 4-bit alpha
262     /// </summary>
263     public static Layout GrannyBGRA4444PixelFormat
264     {
265     get
266     {
267     int bits_per_pixel = 16;
268     int bytes_per_pixel = bits_per_pixel / 8;
269     Layout _layout = new Layout();
270     _layout.BytesPerPixel = bytes_per_pixel;
271     _layout.ShiftForComponent = new int[4] { 8, 4, 0, 12 };
272     _layout.BitsForComponent = new int[4] { 4, 4, 4, 4 };
273     return _layout;
274    
275     }
276     }
277     #endregion
278    
279     #region Pixel Layout: GrannyBGR888PixelFormat
280     /// <summary>
281     /// 24bpp 8-bit blue, 8-bit green, 8-bit red
282     /// </summary>
283     public static Layout GrannyBGR888PixelFormat
284     {
285     get
286     {
287     int bits_per_pixel = 24;
288     int bytes_per_pixel = bits_per_pixel / 8;
289     Layout _layout = new Layout();
290     _layout.BytesPerPixel = bytes_per_pixel;
291     _layout.ShiftForComponent = new int[3] { 16, 8, 0 };
292     _layout.BitsForComponent = new int[3] { 8, 8, 8 };
293     return _layout;
294     }
295     }
296     #endregion
297    
298     #region Pixel Layout: GrannyBGRA8888PixelFormat
299     /// <summary>
300     /// 32bpp 8-bit blue, 8-bit green, 8-bit red, 8-bit alpha
301     /// </summary>
302     public static Layout GrannyBGRA8888PixelFormat
303     {
304     get
305     {
306     int bits_per_pixel = 32;
307     int bytes_per_pixel = bits_per_pixel / 8;
308     Layout _layout = new Layout();
309     _layout.BytesPerPixel = bytes_per_pixel;
310     _layout.ShiftForComponent = new int[4] { 16, 8, 0, 24 };
311     _layout.BitsForComponent = new int[4] { 8, 8, 8, 8 };
312     return _layout;
313     }
314     }
315     #endregion
316     }
317     }

  ViewVC Help
Powered by ViewVC 1.1.22