Skip to content

Commit f1b006d

Browse files
committed
addressed compiler warnings about conversion to Uint8 and possible slight speedup
1 parent 76e012c commit f1b006d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src_c/transform.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4256,8 +4256,8 @@ pixelate(pgSurfaceObject *srcobj, pgSurfaceObject *dstobj, int pixel_size)
42564256
for (y = 0; y < src->h; y += pixel_size) {
42574257
for (x = 0; x < src->w; x += pixel_size) {
42584258
unsigned char r, g, b, a; // current
4259-
Uint64 ra, ga, ba, aa; // averages
4260-
Uint64 size;
4259+
Uint32 ra, ga, ba, aa; // averages
4260+
Uint16 size;
42614261
Uint32 color, average;
42624262
Uint8 *pix;
42634263
int width = (pixel_size > (src->w - x)) ? src->w - x : pixel_size;
@@ -4279,14 +4279,11 @@ pixelate(pgSurfaceObject *srcobj, pgSurfaceObject *dstobj, int pixel_size)
42794279
}
42804280
}
42814281
size = width * height;
4282-
ra /= size;
4283-
ga /= size;
4284-
ba /= size;
4285-
aa /= size;
42864282

4287-
average = SDL_MapRGBA(newsurf->format, ra, ga, ba, aa);
4283+
average = SDL_MapRGBA(newsurf->format, (Uint8)(ra / size),
4284+
(Uint8)(ga / size), (Uint8)(ba / size),
4285+
(Uint8)(aa / size));
42884286

4289-
printf("%u\n", average);
42904287
for (int w = 0; w < width; w++) {
42914288
for (int h = 0; h < height; h++) {
42924289
SURF_SET_AT(average, newsurf, x + w, y + h,

0 commit comments

Comments
 (0)