Fix wrong access and simplify
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index 8c50318..b566f7e 100644
--- a/src/video/SDL_blit_N.c
+++ b/src/video/SDL_blit_N.c
@@ -2178,27 +2178,17 @@ get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt,
b = (Pixel >> 16) & 0xFF;
a = (Pixel >> 24) & 0xFF;
- {
- int val;
- for (val = 0; val <= 3; val++) {
- if (r != val && g != val && b != val && a != val) {
- missing = val;
- break;
- }
- }
- }
-
if (r == 0) {
- r = missing;
+ r = 1;
missing = 0;
} else if (g == 0) {
- g = missing;
+ g = 1;
missing = 1;
} else if (b == 0) {
- b = missing;
+ b = 1;
missing = 2;
} else if (a == 0) {
- a = missing;
+ a = 1;
missing = 3;
}
@@ -2207,7 +2197,7 @@ get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt,
*_b = b - 1;
*_a = a - 1;
- if (missing) {
+ if (_missing) {
*_missing = missing;
}
return;