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); |