Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon_pixelfmt.c @ 3597:7dec3fe9b580
Fixed bug #912
SDL_MasksToPixelFormatEnum() wasn't correctly returning RGB24 formats
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 23 Dec 2009 06:39:18 +0000 |
parents | f96615051c8c |
children | f7b03b6838cb |
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; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
75 case SDL_PIXELFORMAT_RGB555: |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
76 { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
77 return 15; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
78 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
79 break; |
3139 | 80 case SDL_PIXELFORMAT_ABGR1555: |
81 { | |
82 return 15; | |
83 } | |
84 break; | |
85 case SDL_PIXELFORMAT_RGB565: | |
86 { | |
87 return 16; | |
88 } | |
89 break; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
90 case SDL_PIXELFORMAT_RGB24: |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
91 { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
92 return 24; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
93 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
94 break; |
3139 | 95 case SDL_PIXELFORMAT_RGB888: |
96 { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
97 return 32; |
3139 | 98 } |
99 break; | |
100 case SDL_PIXELFORMAT_BGRA8888: | |
101 { | |
102 return 32; | |
103 } | |
104 break; | |
105 case SDL_PIXELFORMAT_ARGB8888: | |
106 { | |
107 return 32; | |
108 } | |
109 break; | |
110 case SDL_PIXELFORMAT_YV12: | |
111 { | |
112 return 8; | |
113 } | |
114 break; | |
115 case SDL_PIXELFORMAT_YUY2: | |
116 { | |
117 return 16; | |
118 } | |
119 break; | |
120 case SDL_PIXELFORMAT_UYVY: | |
121 { | |
122 return 16; | |
123 } | |
124 break; | |
125 case SDL_PIXELFORMAT_YVYU: | |
126 { | |
127 return 16; | |
128 } | |
129 break; | |
130 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
131 |
3139 | 132 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
133 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
134 |
3139 | 135 uint32_t |
136 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
|
137 { |
3139 | 138 switch (pixelfmt) { |
139 case Pg_IMAGE_PALETTE_BYTE: | |
140 { | |
141 return SDL_PIXELFORMAT_INDEX8; | |
142 } | |
143 break; | |
144 case Pg_IMAGE_DIRECT_8888: | |
145 { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
146 return SDL_PIXELFORMAT_ARGB8888; |
3139 | 147 } |
148 break; | |
149 case Pg_IMAGE_DIRECT_888: | |
150 { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
151 return SDL_PIXELFORMAT_RGB24; |
3139 | 152 } |
153 break; | |
154 case Pg_IMAGE_DIRECT_565: | |
155 { | |
156 return SDL_PIXELFORMAT_RGB565; | |
157 } | |
158 break; | |
159 case Pg_IMAGE_DIRECT_555: | |
160 { | |
161 return SDL_PIXELFORMAT_RGB555; | |
162 } | |
163 break; | |
164 case Pg_IMAGE_DIRECT_1555: | |
165 { | |
166 return SDL_PIXELFORMAT_ARGB1555; | |
167 } | |
168 break; | |
169 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
170 |
3139 | 171 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
172 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
173 |
3139 | 174 uint32_t |
175 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
|
176 { |
3139 | 177 switch (pixelfmt) { |
178 case SDL_PIXELFORMAT_INDEX8: | |
179 { | |
180 return Pg_IMAGE_PALETTE_BYTE; | |
181 } | |
182 break; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
183 case SDL_PIXELFORMAT_ARGB8888: |
3139 | 184 { |
185 return Pg_IMAGE_DIRECT_8888; | |
186 } | |
187 break; | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3185
diff
changeset
|
188 case SDL_PIXELFORMAT_RGB888: |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3185
diff
changeset
|
189 { |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3185
diff
changeset
|
190 return Pg_IMAGE_DIRECT_8888; |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3185
diff
changeset
|
191 } |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3185
diff
changeset
|
192 break; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
193 case SDL_PIXELFORMAT_RGB24: |
3139 | 194 { |
195 return Pg_IMAGE_DIRECT_888; | |
196 } | |
197 break; | |
198 case SDL_PIXELFORMAT_RGB565: | |
199 { | |
200 return Pg_IMAGE_DIRECT_565; | |
201 } | |
202 break; | |
203 case SDL_PIXELFORMAT_ARGB1555: | |
204 { | |
205 return Pg_IMAGE_DIRECT_1555; | |
206 } | |
207 break; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
208 case SDL_PIXELFORMAT_RGB555: |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
209 { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
210 return Pg_IMAGE_DIRECT_555; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
211 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
212 break; |
3139 | 213 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
214 |
3139 | 215 return 0; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
216 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
217 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff
changeset
|
218 /* vi: set ts=4 sw=4 expandtab: */ |