This commit is contained in:
Daveo 2001-04-01 20:22:49 +00:00
parent 1966aa6f60
commit 2b171295b5
44 changed files with 588 additions and 603 deletions

View file

@ -47,6 +47,7 @@ int round(float f)
}
//***************************************************************************
/*
void alignFile( FILE *f, int align )
{
long fp = ftell(f);
@ -57,6 +58,17 @@ void alignFile( FILE *f, int align )
fwrite(buffer, s, 1, f);
}
}
*/
//***************************************************************************
void PadFile(FILE *File)
{
int Pad=ftell(File) & 3;
if (Pad)
{
fwrite(&Pad,Pad,1,File);
}
}
//***************************************************************************
GString CheckFileString(const char * Str)
@ -148,3 +160,58 @@ FILE *File=fopen(Name,"rb");
}
return((char*)Name);
}
/**************************************************************************************/
struct sTgaHdr
{
char id; // 0
char colmaptype; // 1
char imagetype; // 2
char fei[2]; // 3
char cml[2]; // 5
char cmes; // 7
short xorig; // 8
short yorig; // 10
short width; // 12
short height; // 14
char depth; // 15
char imagedesc; // 16
};
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR)
{
FILE *File;
sTgaHdr FileHdr;
File=fopen(Filename,"wb");
memset(&FileHdr,0 ,sizeof(sTgaHdr));
FileHdr.imagetype= 2; //imagetype
FileHdr.width = W;
FileHdr.height= H;
FileHdr.depth=24;
fwrite(&FileHdr,sizeof(sTgaHdr),1,File);
if (!IsBGR)
{
fwrite(Data,W*H*3,1,File);
}
else
{
int Size=W*H;
for (int i=0; i<Size;i++)
{
fwrite(&Data[2],1,1,File);
fwrite(&Data[1],1,1,File);
fwrite(&Data[0],1,1,File);
Data+=3;
}
}
fclose(File);
}
//***************************************************

View file

@ -100,6 +100,10 @@ SOURCE=.\facestore.h
# End Source File
# Begin Source File
SOURCE=.\IniClass.h
# End Source File
# Begin Source File
SOURCE=.\List.h
# End Source File
# Begin Source File

View file

@ -66,9 +66,12 @@ void DebugStr();
int round(float f);
void alignFile( FILE *f, int align );
//void alignFile( FILE *f, int align );
void PadFile(FILE *File);
char *FindFile(const char *Name);
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR=false);
//***************************************************************************
#endif

View file

@ -127,7 +127,7 @@ void Export(char *OutFile)
}
/*----------------------------------------------------------------------------*/
char *GetData(char *GroupEntry,char *KeyEntry)
char *GetData(const char *GroupEntry,const char *KeyEntry)
{
int Group=FindGroup(GroupEntry);
if (Group==-1) return(0);
@ -138,14 +138,14 @@ int Entry=FindKey(GroupEntry,KeyEntry);
}
/*----------------------------------------------------------------------------*/
char *GetStr(char *GroupEntry,char *KeyEntry)
char *GetStr(const char *GroupEntry,const char *KeyEntry)
{
char *Str=GetData(GroupEntry,KeyEntry);
return(Str);
}
/*----------------------------------------------------------------------------*/
int GetInt(char *GroupEntry,char *KeyEntry)
int GetInt(const char *GroupEntry,const char *KeyEntry)
{
char *Str=GetData(GroupEntry,KeyEntry);
int Var=0;
@ -153,6 +153,15 @@ int Var=0;
return(Var);
}
/*----------------------------------------------------------------------------*/
bool GetInt(const char *GroupEntry,const char *KeyEntry,int &Var)
{
char *Str=GetData(GroupEntry,KeyEntry);
if (!Str) return(false);
Var=atol(Str);
return(true);
}
/*----------------------------------------------------------------------------*/
int UpdateGroup(char *GroupEntry)
{
@ -241,7 +250,7 @@ void StripGroupName(char *Name)
}
/*----------------------------------------------------------------------------*/
int FindGroup(char *GroupEntry)
int FindGroup(const char *GroupEntry)
{
for (int Loop=0;Loop<IniGroup.size();Loop++)
{
@ -251,7 +260,7 @@ int FindGroup(char *GroupEntry)
}
/*----------------------------------------------------------------------------*/
int FindKey(char *GroupEntry,char *KeyEntry)
int FindKey(const char *GroupEntry,const char *KeyEntry)
{
int Group=FindGroup(GroupEntry);;
if (Group==-1) return(-1);