302 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); |
301 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); |
303 end; |
302 end; |
304 |
303 |
305 if tmpsurf <> nil then |
304 if tmpsurf <> nil then |
306 begin |
305 begin |
307 {$IFDEF DARWIN} |
306 {$IFDEF IPHONEOS} |
308 {* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868 |
307 {* http://bugzilla.libsdl.org/show_bug.cgi?id=868 but patched library doesn't work on ipod, so implementing workaround here *} |
309 remove this when it's fixed in upstream *} |
308 if (ifAlpha or ifTransparent) > 0 then |
310 tmpP := tmpsurf^.pixels; |
|
311 for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do |
|
312 begin |
309 begin |
|
310 tmpP := tmpsurf^.pixels; |
|
311 for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do |
|
312 begin |
313 {$IFDEF ENDIAN_LITTLE} |
313 {$IFDEF ENDIAN_LITTLE} |
314 tmpA:= tmpP^[i] shr 24 and $FF; |
314 tmpA:= tmpP^[i] shr 24 and $FF; |
315 tmpR:= tmpP^[i] shr 16 and $FF; |
315 tmpR:= tmpP^[i] shr 16 and $FF; |
316 tmpG:= tmpP^[i] shr 8 and $FF; |
316 tmpG:= tmpP^[i] shr 8 and $FF; |
317 tmpB:= tmpP^[i] and $FF; |
317 tmpB:= tmpP^[i] and $FF; |
318 {$ELSE} |
318 {$ELSE} |
319 tmpA:= tmpP^[i] and $FF; |
319 tmpA:= tmpP^[i] and $FF; |
320 tmpR:= tmpP^[i] shr 8 and $FF; |
320 tmpR:= tmpP^[i] shr 8 and $FF; |
321 tmpG:= tmpP^[i] shr 16 and $FF; |
321 tmpG:= tmpP^[i] shr 16 and $FF; |
322 tmpB:= tmpP^[i] shr 24 and $FF; |
322 tmpB:= tmpP^[i] shr 24 and $FF; |
323 {$ENDIF} |
323 {$ENDIF} |
324 if tmpA <> 0 then |
324 if tmpA <> 0 then |
325 begin |
325 begin |
326 tmpR:= round(tmpR * 255 / tmpA); |
326 tmpR:= round(tmpR * 255 / tmpA); |
327 tmpG:= round(tmpG * 255 / tmpA); |
327 tmpG:= round(tmpG * 255 / tmpA); |
328 tmpB:= round(tmpB * 255 / tmpA); |
328 tmpB:= round(tmpB * 255 / tmpA); |
|
329 end; |
|
330 |
|
331 if tmpR > 255 then tmpR:= 255; |
|
332 if tmpG > 255 then tmpG:= 255; |
|
333 if tmpB > 255 then tmpB:= 255; |
|
334 |
|
335 {$IFDEF ENDIAN_LITTLE} |
|
336 tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; |
|
337 {$ELSE} |
|
338 tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24); |
|
339 {$ENDIF} |
329 end; |
340 end; |
330 |
|
331 if tmpR > 255 then tmpR:= 255; |
|
332 if tmpG > 255 then tmpG:= 255; |
|
333 if tmpB > 255 then tmpB:= 255; |
|
334 |
|
335 {$IFDEF ENDIAN_LITTLE} |
|
336 tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; |
|
337 {$ELSE} |
|
338 tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24); |
|
339 {$ENDIF} |
|
340 end; |
341 end; |
341 {$ENDIF} |
342 {$ENDIF} |
342 |
343 |
343 if imageWidth = 0 then imageWidth:= tmpsurf^.w; |
344 if imageWidth = 0 then imageWidth:= tmpsurf^.w; |
344 if imageHeight = 0 then imageHeight:= tmpsurf^.h; |
345 if imageHeight = 0 then imageHeight:= tmpsurf^.h; |