Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon_pixelfmt.c @ 3139:7f684f249ec9
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 23 May 2009 22:41:08 +0000 |
parents | aa1897bee1e9 |
children | 44d5474c2c8a |
rev | line source |
---|---|
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
1 /* |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
4 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
9 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
14 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
18 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
19 Sam Lantinga |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
20 slouken@libsdl.org |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
21 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
22 QNX Photon GUI SDL driver |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
23 Copyright (C) 2009 Mike Gorchak |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
24 (mike@malva.ua, lestat@i.com.ua) |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
25 */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
26 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
27 #include "SDL_photon_pixelfmt.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
28 |
3139 | 29 uint32_t |
30 photon_bits_to_sdl_pixelformat(uint32_t pixelfmt) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
31 { |
3139 | 32 switch (pixelfmt) { |
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 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
59 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
60 |
3139 | 61 uint32_t |
62 photon_sdl_to_bits_pixelformat(uint32_t pixelfmt) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
63 { |
3139 | 64 switch (pixelfmt) { |
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 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
121 |
3139 | 122 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
123 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
124 |
3139 | 125 uint32_t |
126 photon_image_to_sdl_pixelformat(uint32_t pixelfmt) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
127 { |
3139 | 128 switch (pixelfmt) { |
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 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
160 |
3139 | 161 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
162 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
163 |
3139 | 164 uint32_t |
165 photon_sdl_to_image_pixelformat(uint32_t pixelfmt) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
166 { |
3139 | 167 switch (pixelfmt) { |
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 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
194 |
3139 | 195 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
196 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
197 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
198 /* vi: set ts=4 sw=4 expandtab: */ |