[NEW] Added LoadTextureFromFile can be usefull ;)

This commit is contained in:
N0NameN0 2009-03-15 18:57:28 +00:00
parent 5bb6d7d5a4
commit 7b3c6c0d16
2 changed files with 24 additions and 0 deletions

View file

@ -485,6 +485,29 @@ GRRLIB_texImg *GRRLIB_LoadTexture(const unsigned char my_img[]) {
}
}
/**
* Load a texture from a file.
* @param filename The JPEG or PNG filename to load.
* @return A GRRLIB_texImg structure filled with image informations.
*/
GRRLIB_texImg *GRRLIB_LoadTextureFromFile(const char *filename) {
fatInitDefault();
FILE *fd = fopen(filename, "rb");
fseek(fd , 0 , SEEK_END);
long lsize = ftell(fd);
rewind(fd);
unsigned char *buffer = (unsigned char*) malloc (sizeof(unsigned char)*lsize);
fread (buffer, 1, lsize, fd);
fclose(fd);
GRRLIB_texImg *tex = GRRLIB_LoadTexture(buffer);
free(buffer);
return tex;
}
/**
* Free memory allocated for texture.
* @param tex A GRRLIB_texImg structure.

View file

@ -109,6 +109,7 @@ GRRLIB_texImg *GRRLIB_CreateEmptyTexture(unsigned int, unsigned int);
GRRLIB_texImg *GRRLIB_LoadTexture(const unsigned char my_img[]);
GRRLIB_texImg *GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]);
GRRLIB_texImg *GRRLIB_LoadTexturePNG(const unsigned char my_png[]);
GRRLIB_texImg *GRRLIB_LoadTextureFromFile(const char *filename);
void GRRLIB_FreeTexture(struct GRRLIB_texImg *tex);
GRRLIB_bytemapFont *GRRLIB_LoadBMF(const unsigned char my_bmf[]);