hedgewars/uMisc.pas
changeset 5046 fc6639d56799
parent 5004 2efa6a414518
child 5050 8eb096ee828e
equal deleted inserted replaced
5045:f215eb5d4b75 5046:fc6639d56799
   116 FreeMem(p)
   116 FreeMem(p)
   117 end;
   117 end;
   118 
   118 
   119 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
   119 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
   120 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   120 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   121 const conversionFormat: TSDL_PixelFormat = (
       
   122 {$IFDEF SDL13}format: 0;{$ENDIF}
       
   123         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
       
   124         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
       
   125 {$IFDEF ENDIAN_LITTLE}Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
       
   126 {$ELSE} Rshift: 24; Gshift: 16; Bshift: 8; Ashift: 0;{$ENDIF}
       
   127         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
       
   128 {$IFDEF SDL13}refcount: 0; next: nil;
       
   129 {$ELSE} colorkey: 0; alpha: 255{$ENDIF});
       
   130 var convertedSurf: PSDL_Surface;
   121 var convertedSurf: PSDL_Surface;
   131 begin
   122 begin
   132     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
   123     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
   133        (tmpsurf^.format^.bitsperpixel = 24) then
   124        (tmpsurf^.format^.bitsperpixel = 24) then
   134         begin
   125         begin
   135         convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
   126         convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE);
   136         SDL_FreeSurface(tmpsurf);
   127         SDL_FreeSurface(tmpsurf);
   137         exit(convertedSurf);
   128         exit(convertedSurf);
   138         end;
   129         end;
   139 
   130 
   140     exit(tmpsurf);
   131     exit(tmpsurf);
   148     GetTeamStatString:= s;
   139     GetTeamStatString:= s;
   149 end;
   140 end;
   150 
   141 
   151 procedure initModule;
   142 procedure initModule;
   152 begin
   143 begin
       
   144     // SDL_PIXELFORMAT_RGB8888
       
   145     conversionFormat:= SDL_AllocFormat($86462004);
   153 end;
   146 end;
   154 
   147 
   155 procedure freeModule;
   148 procedure freeModule;
   156 begin
   149 begin
   157     recordFileName:= '';
   150     recordFileName:= '';
       
   151     SDL_FreeFormat(conversionFormat);
   158 end;
   152 end;
   159 
   153 
   160 end.
   154 end.