@@ -1213,7 +1213,6 @@ set_at(SDL_Surface *surf, int x, int y, Uint32 color)
12131213{
12141214 SDL_PixelFormat * format = surf -> format ;
12151215 Uint8 * pixels = (Uint8 * )surf -> pixels ;
1216- Uint8 * byte_buf , rgb [4 ];
12171216
12181217 if (x < surf -> clip_rect .x || x >= surf -> clip_rect .x + surf -> clip_rect .w ||
12191218 y < surf -> clip_rect .y || y >= surf -> clip_rect .y + surf -> clip_rect .h )
@@ -1230,17 +1229,11 @@ set_at(SDL_Surface *surf, int x, int y, Uint32 color)
12301229 * ((Uint32 * )(pixels + y * surf -> pitch ) + x ) = color ;
12311230 break ;
12321231 default : /*case 3:*/
1233- SDL_GetRGB (color , format , rgb , rgb + 1 , rgb + 2 );
1234- byte_buf = (Uint8 * )(pixels + y * surf -> pitch ) + x * 3 ;
1235- #if (SDL_BYTEORDER == SDL_LIL_ENDIAN )
1236- * (byte_buf + (format -> Rshift >> 3 )) = rgb [0 ];
1237- * (byte_buf + (format -> Gshift >> 3 )) = rgb [1 ];
1238- * (byte_buf + (format -> Bshift >> 3 )) = rgb [2 ];
1239- #else
1240- * (byte_buf + 2 - (format -> Rshift >> 3 )) = rgb [0 ];
1241- * (byte_buf + 2 - (format -> Gshift >> 3 )) = rgb [1 ];
1242- * (byte_buf + 2 - (format -> Bshift >> 3 )) = rgb [2 ];
1232+ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
1233+ color <<= 8 ;
12431234#endif
1235+ memcpy ((pixels + y * surf -> pitch ) + x * 3 , & color ,
1236+ 3 * sizeof (Uint8 ));
12441237 break ;
12451238 }
12461239 return 1 ;
@@ -1805,7 +1798,6 @@ unsafe_set_at(SDL_Surface *surf, int x, int y, Uint32 color)
18051798{
18061799 SDL_PixelFormat * format = surf -> format ;
18071800 Uint8 * pixels = (Uint8 * )surf -> pixels ;
1808- Uint8 * byte_buf , rgb [4 ];
18091801
18101802 switch (PG_FORMAT_BytesPerPixel (format )) {
18111803 case 1 :
@@ -1818,17 +1810,11 @@ unsafe_set_at(SDL_Surface *surf, int x, int y, Uint32 color)
18181810 * ((Uint32 * )(pixels + y * surf -> pitch ) + x ) = color ;
18191811 break ;
18201812 default : /*case 3:*/
1821- SDL_GetRGB (color , format , rgb , rgb + 1 , rgb + 2 );
1822- byte_buf = (Uint8 * )(pixels + y * surf -> pitch ) + x * 3 ;
1823- #if (SDL_BYTEORDER == SDL_LIL_ENDIAN )
1824- * (byte_buf + (format -> Rshift >> 3 )) = rgb [0 ];
1825- * (byte_buf + (format -> Gshift >> 3 )) = rgb [1 ];
1826- * (byte_buf + (format -> Bshift >> 3 )) = rgb [2 ];
1827- #else
1828- * (byte_buf + 2 - (format -> Rshift >> 3 )) = rgb [0 ];
1829- * (byte_buf + 2 - (format -> Gshift >> 3 )) = rgb [1 ];
1830- * (byte_buf + 2 - (format -> Bshift >> 3 )) = rgb [2 ];
1813+ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
1814+ color <<= 8 ;
18311815#endif
1816+ memcpy ((pixels + y * surf -> pitch ) + x * 3 , & color ,
1817+ 3 * sizeof (Uint8 ));
18321818 break ;
18331819 }
18341820}
0 commit comments