aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/UImage.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-12 13:19:17 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-12 13:19:17 +0000
commit3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5 (patch)
treeea37b112534f7ffebe7a1b280cbe282f31ff4f6d /src/base/UImage.pas
parentf2d6710b465289c3e0ce7a8b9844b37be6a15974 (diff)
downloadusdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.tar.gz
usdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.tar.xz
usdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.zip
removed resource.inc
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1371 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base/UImage.pas')
-rw-r--r--src/base/UImage.pas68
1 files changed, 17 insertions, 51 deletions
diff --git a/src/base/UImage.pas b/src/base/UImage.pas
index d33c0d38..5114df25 100644
--- a/src/base/UImage.pas
+++ b/src/base/UImage.pas
@@ -119,7 +119,7 @@ function WriteJPGImage(const FileName: string; Surface: PSDL_Surface; Quality: i
* Image loading
*******************************************************)
-function LoadImage(const Identifier: string): PSDL_Surface;
+function LoadImage(const Filename: string): PSDL_Surface;
(*******************************************************
* Image manipulation
@@ -741,64 +741,30 @@ end;
(*
- * Loads an image from the given file or resource
+ * Loads an image from the given file
*)
-function LoadImage(const Identifier: string): PSDL_Surface;
+function LoadImage(const Filename: string): PSDL_Surface;
var
- TexRWops: PSDL_RWops;
- TexStream: TStream;
- FileName: string;
+ FilenameFound: string;
begin
Result := nil;
- TexRWops := nil;
- if Identifier = '' then
- exit;
+ // FileExistsInsensitive() requires a var-arg
+ FilenameFound := Filename;
- //Log.LogStatus( Identifier, 'LoadImage' );
-
- FileName := Identifier;
-
- if (FileExistsInsensitive(FileName)) then
+ // try to find the file case insensitive
+ if (not FileExistsInsensitive(FilenameFound)) then
begin
- // load from file
- //Log.LogStatus( 'Is File ( Loading : '+FileName+')', ' LoadImage' );
- try
- Result := IMG_Load(PChar(FileName));
- //Log.LogStatus( ' '+inttostr( integer( Result ) ), ' LoadImage' );
- except
- Log.LogError('Could not load from file "'+FileName+'"', 'LoadImage');
- Exit;
- end;
- end
- else
- begin
- //Log.LogStatus( 'IS Resource, because file does not exist.('+Identifier+')', ' LoadImage' );
-
- TexStream := GetResourceStream(Identifier, 'TEX');
- if (not assigned(TexStream)) then
- begin
- Log.LogError( 'Invalid file or resource "'+ Identifier+'"', 'LoadImage');
- Exit;
- end;
-
- TexRWops := RWopsFromStream(TexStream);
- if (TexRWops = nil) then
- begin
- Log.LogError( 'Could not assign resource "'+Identifier+'"', 'LoadImage');
- TexStream.Free();
- Exit;
- end;
-
- //Log.LogStatus( 'resource Assigned....' , Identifier);
- try
- Result := IMG_Load_RW(TexRWops, 0);
- except
- Log.LogError( 'Could not read resource "'+Identifier+'"', 'LoadImage');
- end;
+ Log.LogError('Image-File does not exist "'+FilenameFound+'"', 'LoadImage');
+ Exit;
+ end;
- SDL_FreeRW(TexRWops);
- TexStream.Free();
+ // load from file
+ try
+ Result := IMG_Load(PChar(FilenameFound));
+ except
+ Log.LogError('Could not load from file "'+FilenameFound+'"', 'LoadImage');
+ Exit;
end;
end;