From 5ce375d1b7493e41a3ac14b979932d6cf7d73285 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 24 Mar 2007 13:37:12 +0000 Subject: Copyed PNG Texture Support from UltraStar 0.5.3 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@23 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UTexture.pas | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'Game/Code/Classes/UTexture.pas') diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas index 767d53ec..b50ab6bf 100644 --- a/Game/Code/Classes/UTexture.pas +++ b/Game/Code/Classes/UTexture.pas @@ -11,7 +11,7 @@ unit UTexture; // Arrow (for arrows, white is white, gray has color, black is transparent); interface -uses OpenGL12, Windows, Math, Classes, SysUtils, Graphics, JPEG, UThemes; +uses OpenGL12, Windows, Math, Classes, SysUtils, Graphics, JPEG, UThemes, PNGImage; procedure glGenTextures(n: GLsizei; var textures: GLuint); stdcall; external opengl32; //procedure glBindTexture(target: GLenum; texture: GLuint); stdcall; external opengl32; @@ -192,6 +192,7 @@ var Res: TResourceStream; TextureB: TBitmap; TextureJ: TJPEGImage; + TexturePNG: TPNGObject; Pet: integer; Pet2: integer; @@ -215,10 +216,14 @@ begin end; if FromRegistry or ((not FromRegistry) and FileExists(Nazwa)) then begin - TextureB := TBitmap.Create; - if Format = 'JPG' then begin + if Format = 'BMP' then begin + if FromRegistry then TextureB.LoadFromStream(Res) + else TextureB.LoadFromFile(Nazwa); + end + + else if Format = 'JPG' then begin TextureJ := TJPEGImage.Create; if FromRegistry then TextureJ.LoadFromStream(Res) else begin @@ -229,10 +234,19 @@ begin end; TextureB.Assign(TextureJ); TextureJ.Free; - end; - if Format = 'BMP' then begin - if FromRegistry then TextureB.LoadFromStream(Res) - else TextureB.LoadFromFile(Nazwa); + end + + else if Format = 'PNG' then begin + TexturePNG := TPNGObject.Create; + if FromRegistry then TexturePNG.LoadFromStream(Res) + else begin + if FileExists(Nazwa) then + TexturePNG.LoadFromFile(Nazwa) + else + Exit; + end; + TextureB.Assign(TexturePNG); + TexturePNG.Free; end; if FromRegistry then Res.Free; -- cgit v1.2.3