src/video/SDL_surface.c
changeset 12584 233b2a61cad1
parent 12566 884f99b039f0
child 12587 b2d4dcb4ba33
equal deleted inserted replaced
12583:338b02acfdfc 12584:233b2a61cad1
   955 {
   955 {
   956     SDL_Surface *convert;
   956     SDL_Surface *convert;
   957     Uint32 copy_flags;
   957     Uint32 copy_flags;
   958     SDL_Color copy_color;
   958     SDL_Color copy_color;
   959     SDL_Rect bounds;
   959     SDL_Rect bounds;
       
   960     int ret;
   960 
   961 
   961     if (!surface) {
   962     if (!surface) {
   962         SDL_InvalidParamError("surface");
   963         SDL_InvalidParamError("surface");
   963         return NULL;
   964         return NULL;
   964     }
   965     }
  1015     /* Copy over the image data */
  1016     /* Copy over the image data */
  1016     bounds.x = 0;
  1017     bounds.x = 0;
  1017     bounds.y = 0;
  1018     bounds.y = 0;
  1018     bounds.w = surface->w;
  1019     bounds.w = surface->w;
  1019     bounds.h = surface->h;
  1020     bounds.h = surface->h;
  1020     SDL_LowerBlit(surface, &bounds, convert, &bounds);
  1021     ret = SDL_LowerBlit(surface, &bounds, convert, &bounds);
  1021 
  1022 
  1022     /* Clean up the original surface, and update converted surface */
  1023     /* Clean up the original surface, and update converted surface */
  1023     convert->map->info.r = copy_color.r;
  1024     convert->map->info.r = copy_color.r;
  1024     convert->map->info.g = copy_color.g;
  1025     convert->map->info.g = copy_color.g;
  1025     convert->map->info.b = copy_color.b;
  1026     convert->map->info.b = copy_color.b;
  1033     surface->map->info.g = copy_color.g;
  1034     surface->map->info.g = copy_color.g;
  1034     surface->map->info.b = copy_color.b;
  1035     surface->map->info.b = copy_color.b;
  1035     surface->map->info.a = copy_color.a;
  1036     surface->map->info.a = copy_color.a;
  1036     surface->map->info.flags = copy_flags;
  1037     surface->map->info.flags = copy_flags;
  1037     SDL_InvalidateMap(surface->map);
  1038     SDL_InvalidateMap(surface->map);
       
  1039 
       
  1040     /* SDL_LowerBlit failed, and so the conversion */
       
  1041     if (ret < 0) {
       
  1042         SDL_FreeSurface(convert);
       
  1043         return NULL;
       
  1044     }
       
  1045 
  1038     if (copy_flags & SDL_COPY_COLORKEY) {
  1046     if (copy_flags & SDL_COPY_COLORKEY) {
  1039         SDL_bool set_colorkey_by_color = SDL_FALSE;
  1047         SDL_bool set_colorkey_by_color = SDL_FALSE;
  1040         SDL_bool ignore_alpha          = SDL_TRUE;  /* Ignore, or not, alpha in colorkey comparison */
  1048         SDL_bool ignore_alpha          = SDL_TRUE;  /* Ignore, or not, alpha in colorkey comparison */
  1041 
  1049 
  1042         if (surface->format->palette) {
  1050         if (surface->format->palette) {