src/video/SDL_surface.c
changeset 11289 ca3c2c98f2e1
parent 11254 390de4b9f84f
child 11448 52dcef74bdc5
equal deleted inserted replaced
11288:47a5a4999180 11289:ca3c2c98f2e1
   869         SDL_RLESurface(surface);
   869         SDL_RLESurface(surface);
   870     }
   870     }
   871 }
   871 }
   872 
   872 
   873 /*
   873 /*
       
   874  * Creates a new surface identical to the existing surface
       
   875  */
       
   876 SDL_Surface *
       
   877 SDL_DuplicateSurface(SDL_Surface * surface)
       
   878 {
       
   879     return SDL_ConvertSurface(surface, surface->format, surface->flags);
       
   880 }
       
   881 
       
   882 /*
   874  * Convert a surface into the specified pixel format.
   883  * Convert a surface into the specified pixel format.
   875  */
   884  */
   876 SDL_Surface *
   885 SDL_Surface *
   877 SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
   886 SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
   878                    Uint32 flags)
   887                    Uint32 flags)
   879 {
   888 {
   880     SDL_Surface *convert;
   889     SDL_Surface *convert;
   881     Uint32 copy_flags;
   890     Uint32 copy_flags;
   882     SDL_Color copy_color;
   891     SDL_Color copy_color;
   883     SDL_Rect bounds;
   892     SDL_Rect bounds;
       
   893 
       
   894     if (!surface) {
       
   895         SDL_InvalidParamError("surface");
       
   896         return NULL;
       
   897     }
       
   898     if (!format) {
       
   899         SDL_InvalidParamError("format");
       
   900         return NULL;
       
   901     }
   884 
   902 
   885     /* Check for empty destination palette! (results in empty image) */
   903     /* Check for empty destination palette! (results in empty image) */
   886     if (format->palette != NULL) {
   904     if (format->palette != NULL) {
   887         int i;
   905         int i;
   888         for (i = 0; i < format->palette->ncolors; ++i) {
   906         for (i = 0; i < format->palette->ncolors; ++i) {