Debian Codegraph @

src/effect/EffectReverse.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "EffectReverse.h"
10
11 #include "SurfaceLock.h"
12 #include "PixelTool.h"
13
14 const char *EffectReverse::NAME = "reverse";
15 //-----------------------------------------------------------------
16 /**
17 * Reverse left and right.
18 */
19 void
20 EffectReverse::blit(SDL_Surface *screen, SDL_Surface *surface, int x, int y)
21 {
22 SurfaceLock lock1(screen);
23 SurfaceLock lock2(surface);
24
25 for (int py = 0; py < surface->h; ++py) {
26 for (int px = 0; px < surface->w; ++px) {
27 SDL_Color pixel = PixelTool::getColor(surface, px, py);
28 if (pixel.unused == 255) {
29 PixelTool::putColor(screen,
30 x + surface->w - 1 - px, y + py, pixel);
31 }
32 }
33 }
34 }
35