This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, generate has been updated via efe1e66de81808a60c5c3d3e91ae50eb973cf733 (commit) from 570b772500147f49fedbc21b6d2aedc7be13a16b (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/efe1e66de81808a60c5c3d3e91ae50eb973cf...
commit efe1e66de81808a60c5c3d3e91ae50eb973cf733 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 22 20:07:31 2011 +0200
Added function to load image of any supported format.
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h index 99253bf..a245e9a 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Loaders.h @@ -32,10 +32,17 @@ #ifndef GP_LOADERS_H #define GP_LOADERS_H
+#include "core/GP_Context.h" + #include "GP_PBM.h" #include "GP_PGM.h" #include "GP_PPM.h"
#include "GP_PNG.h"
+/* + * Tries to load image accordingly to extension. + */ +GP_RetCode GP_LoadImage(const char *src_path, GP_Context **res); + #endif /* GP_LOADERS_H */ diff --git a/include/loaders/GP_Loaders.h b/libs/loaders/GP_Loaders.c similarity index 61% copy from include/loaders/GP_Loaders.h copy to libs/loaders/GP_Loaders.c index 99253bf..72e2a31 100644 --- a/include/loaders/GP_Loaders.h +++ b/libs/loaders/GP_Loaders.c @@ -16,26 +16,65 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
- /* +/* + + General functions for loading bitmaps. + + */
- Core include file for loaders API. +#include <string.h>
- */ +#include "GP_Loaders.h"
-#ifndef GP_LOADERS_H -#define GP_LOADERS_H +GP_RetCode GP_LoadImage(const char *src_path, GP_Context **res) +{ + int len = strlen(src_path); + GP_RetCode ret = GP_ENOIMPL;
-#include "GP_PBM.h" -#include "GP_PGM.h" -#include "GP_PPM.h" + switch (src_path[len - 1]) { + /* PNG, JPG, JPEG */ + case 'g': + case 'G': + switch (src_path[len - 2]) { + case 'n': + case 'N': + if (src_path[len - 3] == 'p' || + src_path[len - 3] == 'P') + ret = GP_LoadPNG(src_path, res); + break; + } + break; + /* PPM, PGM, PBM, PNM */ + case 'm': + case 'M': + switch (src_path[len - 2]) { + case 'b': + case 'B': + if (src_path[len - 3] == 'p' || + src_path[len - 3] == 'P') + ret = GP_LoadPBM(src_path, res); + break; + case 'g': + case 'G': + if (src_path[len - 3] == 'p' || + src_path[len - 3] == 'P') + ret = GP_LoadPGM(src_path, res); + break; + case 'p': + case 'P': + if (src_path[len - 3] == 'p' || + src_path[len - 3] == 'P') + ret = GP_LoadPPM(src_path, res); + break; + } + break; + }
-#include "GP_PNG.h" + //TODO file signature based check
-#endif /* GP_LOADERS_H */ + return ret; +} diff --git a/tests/SDL/showimage.c b/tests/SDL/showimage.c index 9ef23f1..937296d 100644 --- a/tests/SDL/showimage.c +++ b/tests/SDL/showimage.c @@ -92,7 +92,7 @@ int main(int argc, char *argv[])
GP_RetCode ret;
- if ((ret = GP_LoadPPM(argv[1], &bitmap))) { + if ((ret = GP_LoadImage(argv[1], &bitmap))) { fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); return 1; }
-----------------------------------------------------------------------
Summary of changes: include/loaders/GP_Loaders.h | 7 ++ .../GP_ScaleDown.c => loaders/GP_Loaders.c} | 74 +++++++++++++------ tests/SDL/showimage.c | 2 +- 3 files changed, 58 insertions(+), 25 deletions(-) copy libs/{filters/GP_ScaleDown.c => loaders/GP_Loaders.c} (62%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.