mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-25 16:22:20 +00:00
[NEW] Added LoadTextureFromFile can be usefull ;)
This commit is contained in:
parent
5bb6d7d5a4
commit
7b3c6c0d16
2 changed files with 24 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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[]);
|
||||
|
|
Loading…
Reference in a new issue