diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-20 10:53:12 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-20 10:53:12 +0000 |
commit | efef73dfde7de1692afb9aa8a9d51dcafc59fbb2 (patch) | |
tree | b2cbe590dc1a118571892bfc3f1299f24756452e /Game/Code | |
parent | 50523ba17fcb19d37c54420ec3ea651538121e35 (diff) | |
download | usdx-efef73dfde7de1692afb9aa8a9d51dcafc59fbb2.tar.gz usdx-efef73dfde7de1692afb9aa8a9d51dcafc59fbb2.tar.xz usdx-efef73dfde7de1692afb9aa8a9d51dcafc59fbb2.zip |
started re-factoring TTextureUnit.LoadTexture
only done BPM and JPEG for now.
will do more as I add support for it to lazarus.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@418 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UTexture.pas | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas index 364bbcc8..e7038e78 100644 --- a/Game/Code/Classes/UTexture.pas +++ b/Game/Code/Classes/UTexture.pas @@ -90,7 +90,8 @@ type TTextureUnit = class
private
- function LoadBitmap( aSourceStream : TStream; aBMP : TBitMap ): boolean;
+ function LoadBitmap( aSourceStream : TStream; aIMG : TBitMap ): boolean;
+ function LoadJpeg( aSourceStream : TStream; aIMG : TBitMap ): boolean;
public
Limit: integer;
CreateCacheMipmap: boolean;
@@ -311,12 +312,40 @@ begin end;
-function TTextureUnit.LoadBitmap( aSourceStream : TStream; aBMP : TBitMap ): boolean;
+function TTextureUnit.LoadBitmap( aSourceStream : TStream; aIMG : TBitMap ): boolean;
begin
- aSourceStream.position := 0;
- boolean := aBMP.LoadFromStream( aSourceStream ) > 0;
+ result := false;
+ try
+ aSourceStream.position := 0;
+ aIMG.LoadFromStream( aSourceStream );
+ finally
+ result := aSourceStream.position > 0;
+ end;
+end;
+
+function TTextureUnit.LoadJpeg( aSourceStream : TStream; aIMG : TBitMap ): boolean;
+var
+ TextureJ: TJPEGImage;
+begin
+ result := false;
+ try
+ aSourceStream.position := 0;
+
+ TextureJ := TJPEGImage.Create;
+ try
+ TextureJ.LoadFromStream( aSourceStream );
+ aIMG.Assign(TextureJ);
+ finally
+ TextureJ.Free;
+ end;
+ finally
+ result := aSourceStream.position > 0;
+ end;
end;
+
+
+
function TTextureUnit.LoadTexture(FromRegistry: boolean; Identifier, Format, Typ: PChar; Col: LongWord): TTexture;
var
Res: TResourceStream;
@@ -381,38 +410,16 @@ begin end;
end;
- if FromRegistry or
- ((not FromRegistry) and FileExists(Identifier)) then
+// if FromRegistry or
+// ((not FromRegistry) and FileExists(Identifier)) then
begin
- TextureB := TBitmap.Create;
+ TextureB := TBitmap.Create;
if Format = 'BMP' then
- begin
- LoadBitmap( aSourceStream : TStream; TextureB );
-
- if FromRegistry then
- TextureB.LoadFromStream(Res)
- else
- TextureB.LoadFromFile(Identifier);
- end
+ LoadBitmap( lTextureStream , TextureB )
else
if Format = 'JPG' then
- begin
- TextureJ := TJPEGImage.Create;
-
- if FromRegistry then
- TextureJ.LoadFromStream(Res)
- else
- begin
- if FileExists(Identifier) then
- TextureJ.LoadFromFile(Identifier)
- else
- Exit;
- end;
-
- TextureB.Assign(TextureJ);
- TextureJ.Free;
- end
+ LoadJpeg( lTextureStream , TextureB )
else if Format = 'PNG' then
begin
{$IFNDEF FPC}
|