@@ -2478,8 +2478,9 @@ draw_line(SDL_Surface *surf, SDL_Rect surf_clip_rect, int x1, int y1, int x2,
24782478 }
24792479 set_and_check_rect (surf , surf_clip_rect , x2 , y2 , color , drawn_area );
24802480}
2481- #define SURF_GET_AT (p_color , p_surf , p_x , p_y , p_pixels , p_pix ) \
2482- switch (PG_SURF_BytesPerPixel(p_surf)) { \
2481+ #ifndef SURF_GET_AT
2482+ #define SURF_GET_AT (p_color , p_surf , p_x , p_y , p_pixels , p_format , p_pix ) \
2483+ switch (PG_FORMAT_BytesPerPixel(p_format)) { \
24832484 case 1: \
24842485 p_color = (Uint32) * \
24852486 ((Uint8 *)(p_pixels) + (p_y) * p_surf->pitch + (p_x)); \
@@ -2501,6 +2502,7 @@ draw_line(SDL_Surface *surf, SDL_Rect surf_clip_rect, int x1, int y1, int x2,
25012502 * ((Uint32 * )(p_pixels + (p_y ) * p_surf -> pitch ) + (p_x )); \
25022503 break ; \
25032504 }
2505+ #endif //SURF_GET_AT
25042506
25052507static int
25062508flood_fill_inner (SDL_Surface * surf , int x1 , int y1 , Uint32 new_color ,
@@ -2509,6 +2511,10 @@ flood_fill_inner(SDL_Surface *surf, int x1, int y1, Uint32 new_color,
25092511 // breadth first flood fill, like graph search
25102512 SDL_Rect cliprect ;
25112513 size_t mask_idx ;
2514+ PG_PixelFormat * format = PG_GetSurfaceFormat (surf );
2515+ if (!format ) {
2516+ return -1 ;
2517+ }
25122518 if (!PG_GetSurfaceClipRect (surf , & cliprect )) {
25132519 return -1 ;
25142520 }
@@ -2554,7 +2560,7 @@ flood_fill_inner(SDL_Surface *surf, int x1, int y1, Uint32 new_color,
25542560 goto flood_fill_finished ;
25552561 }
25562562
2557- SURF_GET_AT (old_color , surf , x1 , y1 , (Uint8 * )surf -> pixels , pix );
2563+ SURF_GET_AT (old_color , surf , x1 , y1 , (Uint8 * )surf -> pixels , format , pix );
25582564
25592565 if (pattern == NULL && old_color == new_color ) {
25602566 // not an error, but nothing to do here
@@ -2577,15 +2583,16 @@ flood_fill_inner(SDL_Surface *surf, int x1, int y1, Uint32 new_color,
25772583
25782584 Uint32 current_color = 0 ;
25792585
2580- SURF_GET_AT (current_color , surf , x , y , (Uint8 * )surf -> pixels , pix );
2586+ SURF_GET_AT (current_color , surf , x , y , (Uint8 * )surf -> pixels ,
2587+ format , pix );
25812588
25822589 if (current_color != old_color ) {
25832590 continue ;
25842591 }
25852592
25862593 if (pattern != NULL ) {
25872594 SURF_GET_AT (new_color , pattern , x % pattern -> w , y % pattern -> h ,
2588- (Uint8 * )pattern -> pixels , pix );
2595+ (Uint8 * )pattern -> pixels , format , pix );
25892596 }
25902597
25912598 // clipping and color mapping have already happened here
0 commit comments