Mercurial > sdl-ios-xcode
comparison src/video/SDL_surface.c @ 2786:6bacfecbf27e
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 25 Nov 2008 02:21:53 +0000 |
parents | fa1095d42a5b |
children | 93764fe8601a |
comparison
equal
deleted
inserted
replaced
2785:fa1095d42a5b | 2786:6bacfecbf27e |
---|---|
269 return 0; | 269 return 0; |
270 } | 270 } |
271 | 271 |
272 /* This is a fairly slow function to switch from colorkey to alpha */ | 272 /* This is a fairly slow function to switch from colorkey to alpha */ |
273 void | 273 void |
274 SDL_ConvertColorkeyToAlpha(SDL_Surface *surface) | 274 SDL_ConvertColorkeyToAlpha(SDL_Surface * surface) |
275 { | 275 { |
276 int x, y; | 276 int x, y; |
277 | 277 |
278 if (!surface) { | 278 if (!surface) { |
279 return; | 279 return; |
280 } | 280 } |
281 | 281 |
282 if (!(surface->map->info.flags & SDL_COPY_COLORKEY) || | 282 if (!(surface->map->info.flags & SDL_COPY_COLORKEY) || |
283 !surface->format->Amask) { | 283 !surface->format->Amask) { |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 SDL_LockSurface(surface); | 287 SDL_LockSurface(surface); |
288 | 288 |
289 switch (surface->format->BytesPerPixel) { | 289 switch (surface->format->BytesPerPixel) { |
290 case 2: | 290 case 2: |
291 { | 291 { |
292 Uint16 *row, *spot; | 292 Uint16 *row, *spot; |
293 Uint16 ckey = (Uint16)surface->map->info.colorkey; | 293 Uint16 ckey = (Uint16) surface->map->info.colorkey; |
294 Uint16 mask = (Uint16)(~surface->format->Amask); | 294 Uint16 mask = (Uint16) (~surface->format->Amask); |
295 | 295 |
296 row = (Uint16 *)surface->pixels; | 296 row = (Uint16 *) surface->pixels; |
297 for (y = surface->h; y--; ) { | 297 for (y = surface->h; y--;) { |
298 spot = row; | 298 spot = row; |
299 for (x = surface->w; x--; ) { | 299 for (x = surface->w; x--;) { |
300 if (*spot == ckey) { | 300 if (*spot == ckey) { |
301 *spot &= mask; | 301 *spot &= mask; |
302 } | 302 } |
303 ++spot; | 303 ++spot; |
304 } | 304 } |
305 row += surface->pitch / 2; | 305 row += surface->pitch / 2; |
306 } | 306 } |
307 } | 307 } |
308 break; | 308 break; |
309 case 3: | 309 case 3: |
310 /* FIXME */ | 310 /* FIXME */ |
311 break; | 311 break; |
312 case 4: | 312 case 4: |
313 { | 313 { |
314 Uint32 *row, *spot; | 314 Uint32 *row, *spot; |
315 Uint32 ckey = surface->map->info.colorkey; | 315 Uint32 ckey = surface->map->info.colorkey; |
316 Uint32 mask = ~surface->format->Amask; | 316 Uint32 mask = ~surface->format->Amask; |
317 | 317 |
318 row = (Uint32 *)surface->pixels; | 318 row = (Uint32 *) surface->pixels; |
319 for (y = surface->h; y--; ) { | 319 for (y = surface->h; y--;) { |
320 spot = row; | 320 spot = row; |
321 for (x = surface->w; x--; ) { | 321 for (x = surface->w; x--;) { |
322 if (*spot == ckey) { | 322 if (*spot == ckey) { |
323 *spot &= mask; | 323 *spot &= mask; |
324 } | 324 } |
325 ++spot; | 325 ++spot; |
326 } | 326 } |
327 row += surface->pitch / 4; | 327 row += surface->pitch / 4; |
328 } | 328 } |
329 } | 329 } |
330 break; | 330 break; |
331 } | 331 } |
332 | 332 |
333 SDL_UnlockSurface(surface); | 333 SDL_UnlockSurface(surface); |
334 | 334 |
335 SDL_SetColorKey(surface, 0, 0); | 335 SDL_SetColorKey(surface, 0, 0); |
336 } | 336 } |
337 | 337 |
338 int | 338 int |
339 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) | 339 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) |
340 { | 340 { |