summary refs log tree commit diff
path: root/src/TGALoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/TGALoader.cpp')
-rw-r--r--src/TGALoader.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/TGALoader.cpp b/src/TGALoader.cpp
index 27fd5b9..ea26920 100644
--- a/src/TGALoader.cpp
+++ b/src/TGALoader.cpp
@@ -1,10 +1,9 @@
 /**> HEADER FILES <**/
 #include "TGALoader.h"
 
-
 /********************> LoadTGA() <*****/
 TGAImageRec*	LoadTGA( char *filename )
-{    
+{
 	GLubyte			TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};	// Uncompressed TGA Header
 	GLubyte			TGAcompare[12];								// Used To Compare TGA Header
 	GLubyte			header[6];									// First 6 Useful Bytes From The Header
@@ -13,7 +12,7 @@ TGAImageRec*	LoadTGA( char *filename )
 	GLuint			temp;										// Temporary Variable
 	TGAImageRec		*texture;
 	FILE			*file;
-	
+
 	// Open The TGA File
 	file = cfh_fopen( filename, "rb" );
 
@@ -26,14 +25,14 @@ TGAImageRec*	LoadTGA( char *filename )
 		fclose( file );
 		return NULL;
 	}
-	
+
 	// Create a new RGBAImageRec
 	texture = ( TGAImageRec* )malloc( sizeof( TGAImageRec ) );
-	
+
 	// Determine the TGA width (highbyte*256+lowbyte) and height (highbyte*256+lowbyte)
 	texture->sizeX  = header[1] * 256 + header[0];
 	texture->sizeY = header[3] * 256 + header[2];
-    
+
     // Make sure the height, width, and bit depth are valid
  	if(	( texture->sizeX <= 0 ) || ( texture->sizeY <= 0 ) || ( ( header[4] != 24 ) && ( header[4] != 32 ) ) )
 	{
@@ -42,17 +41,17 @@ TGAImageRec*	LoadTGA( char *filename )
 		free( texture );
 		return NULL;
 	}
-	
+
 	// Grab The TGA's Bits Per Pixel (24 or 32)
-	texture->bpp = header[4];							
+	texture->bpp = header[4];
 	bytesPerPixel = texture->bpp/8;	// Divide By 8 To Get The Bytes Per Pixel
-	
+
 	// Calculate The Memory Required For The TGA Data
 	imageSize = texture->sizeX * texture->sizeY * bytesPerPixel;
-	
+
 	// Reserve Memory To Hold The TGA Data
-	texture->data = ( GLubyte* )malloc( imageSize );		
-	
+	texture->data = ( GLubyte* )malloc( imageSize );
+
 	// Make sure the right amount of memory was allocated
 	if(	( texture->data == NULL ) || ( fread( texture->data, 1, imageSize, file ) != imageSize ) )
 	{
@@ -65,7 +64,7 @@ TGAImageRec*	LoadTGA( char *filename )
 		free( texture );
 		return NULL;
 	}
-	
+
 	// Loop Through The Image Data
 	for( GLuint i = 0; i < int( imageSize ); i += bytesPerPixel )
 	{
@@ -74,9 +73,9 @@ TGAImageRec*	LoadTGA( char *filename )
 		texture->data[i] = texture->data[i + 2];	// Set The 1st Byte To The Value Of The 3rd Byte
 		texture->data[i + 2] = temp;				// Set The 3rd Byte To The Value In 'temp' (1st Byte Value)
 	}
-	
+
 	// Close The File
 	fclose( file );
-	
+
 	return texture;
 }