comparison src/video/photon/SDL_photon_pixelfmt.c @ 3108:aa1897bee1e9

Continue working on QNX Photon with OpenGL ES support
author Mike Gorchak <lestat@i.com.ua>
date Tue, 28 Apr 2009 04:30:52 +0000
parents
children 7f684f249ec9
comparison
equal deleted inserted replaced
3107:3cf236d3cd81 3108:aa1897bee1e9
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21
22 QNX Photon GUI SDL driver
23 Copyright (C) 2009 Mike Gorchak
24 (mike@malva.ua, lestat@i.com.ua)
25 */
26
27 #include "SDL_photon_pixelfmt.h"
28
29 uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
30 {
31 switch(pixelfmt)
32 {
33 case 8:
34 {
35 return SDL_PIXELFORMAT_INDEX8;
36 }
37 break;
38 case 15:
39 {
40 return SDL_PIXELFORMAT_ARGB1555;
41 }
42 break;
43 case 16:
44 {
45 return SDL_PIXELFORMAT_RGB565;
46 }
47 break;
48 case 24:
49 {
50 return SDL_PIXELFORMAT_RGB888;
51 }
52 break;
53 case 32:
54 {
55 return SDL_PIXELFORMAT_ARGB8888;
56 }
57 break;
58 }
59 }
60
61 uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
62 {
63 switch(pixelfmt)
64 {
65 case SDL_PIXELFORMAT_INDEX8:
66 {
67 return 8;
68 }
69 break;
70 case SDL_PIXELFORMAT_ARGB1555:
71 {
72 return 15;
73 }
74 break;
75 case SDL_PIXELFORMAT_ABGR1555:
76 {
77 return 15;
78 }
79 break;
80 case SDL_PIXELFORMAT_RGB565:
81 {
82 return 16;
83 }
84 break;
85 case SDL_PIXELFORMAT_RGB888:
86 {
87 return 24;
88 }
89 break;
90 case SDL_PIXELFORMAT_BGRA8888:
91 {
92 return 32;
93 }
94 break;
95 case SDL_PIXELFORMAT_ARGB8888:
96 {
97 return 32;
98 }
99 break;
100 case SDL_PIXELFORMAT_YV12:
101 {
102 return 8;
103 }
104 break;
105 case SDL_PIXELFORMAT_YUY2:
106 {
107 return 16;
108 }
109 break;
110 case SDL_PIXELFORMAT_UYVY:
111 {
112 return 16;
113 }
114 break;
115 case SDL_PIXELFORMAT_YVYU:
116 {
117 return 16;
118 }
119 break;
120 }
121
122 return 0;
123 }
124
125 uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
126 {
127 switch(pixelfmt)
128 {
129 case Pg_IMAGE_PALETTE_BYTE:
130 {
131 return SDL_PIXELFORMAT_INDEX8;
132 }
133 break;
134 case Pg_IMAGE_DIRECT_8888:
135 {
136 return SDL_PIXELFORMAT_BGRA8888;
137 }
138 break;
139 case Pg_IMAGE_DIRECT_888:
140 {
141 return SDL_PIXELFORMAT_RGB888;
142 }
143 break;
144 case Pg_IMAGE_DIRECT_565:
145 {
146 return SDL_PIXELFORMAT_RGB565;
147 }
148 break;
149 case Pg_IMAGE_DIRECT_555:
150 {
151 return SDL_PIXELFORMAT_RGB555;
152 }
153 break;
154 case Pg_IMAGE_DIRECT_1555:
155 {
156 return SDL_PIXELFORMAT_ARGB1555;
157 }
158 break;
159 }
160
161 return 0;
162 }
163
164 uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
165 {
166 switch(pixelfmt)
167 {
168 case SDL_PIXELFORMAT_INDEX8:
169 {
170 return Pg_IMAGE_PALETTE_BYTE;
171 }
172 break;
173 case SDL_PIXELFORMAT_BGRA8888:
174 {
175 return Pg_IMAGE_DIRECT_8888;
176 }
177 break;
178 case SDL_PIXELFORMAT_RGB888:
179 {
180 return Pg_IMAGE_DIRECT_888;
181 }
182 break;
183 case SDL_PIXELFORMAT_RGB565:
184 {
185 return Pg_IMAGE_DIRECT_565;
186 }
187 break;
188 case SDL_PIXELFORMAT_ARGB1555:
189 {
190 return Pg_IMAGE_DIRECT_1555;
191 }
192 break;
193 }
194
195 return 0;
196 }
197
198 /* vi: set ts=4 sw=4 expandtab: */