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, master has been updated via 156709b6343ea54485a3d662ddc66448e3337c76 (commit) from a960a02a7e253fcdd2ec0cfa64f7d2f513719961 (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/156709b6343ea54485a3d662ddc66448e3337...
commit 156709b6343ea54485a3d662ddc66448e3337c76 Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 4 22:39:30 2012 +0100
loaders: More signature matching, yay!
diff --git a/include/loaders/GP_GIF.h b/include/loaders/GP_GIF.h index 1eb87ff..62284d0 100644 --- a/include/loaders/GP_GIF.h +++ b/include/loaders/GP_GIF.h @@ -58,4 +58,9 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback); */ GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
+/* + * Match GIF signature. + */ +int GP_MatchGIF(const void *buf); + #endif /* LOADERS_GP_GIF_H */ diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h index 73113c4..5906b11 100644 --- a/include/loaders/GP_JPG.h +++ b/include/loaders/GP_JPG.h @@ -62,4 +62,9 @@ int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data); int GP_SaveJPG(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
+/* + * Match JPG signature. + */ +int GP_MatchJPG(const void *buf); + #endif /* LOADERS_GP_JPG_H */ diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h index 3a8f2f8..4b6e3bb 100644 --- a/include/loaders/GP_PNG.h +++ b/include/loaders/GP_PNG.h @@ -79,4 +79,9 @@ int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data); int GP_SavePNG(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
+/* + * Match PNG signature. + */ +int GP_MatchPNG(const void *buf); + #endif /* LOADERS_GP_PNG_H */ diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c index 262e5d9..c4e2d2e 100644 --- a/libs/loaders/GP_GIF.c +++ b/libs/loaders/GP_GIF.c @@ -44,6 +44,23 @@
#include <gif_lib.h>
+#define GIF_SIGNATURE1 "GIF87a" +#define GIF_SIGNATURE1_LEN 6 + +#define GIF_SIGNATURE2 "GIF89a" +#define GIF_SIGNATURE2_LEN 6 + +int GP_MatchGIF(const void *buf) +{ + if (!memcmp(buf, GIF_SIGNATURE1, GIF_SIGNATURE1_LEN)) + return 1; + + if (!memcmp(buf, GIF_SIGNATURE2, GIF_SIGNATURE2_LEN)) + return 1; + + return 0; +} + int GP_OpenGIF(const char *src_path, void **f) { GifFileType *gf; diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index bece7d5..bc47c4b 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -43,6 +43,18 @@
#include <jpeglib.h>
+/* + * 0xff 0xd8 - start of image + * 0xff 0xe0 - APP0 JFIF meta data + */ +#define JPEG_SIGNATURE "xffxd8xffxe0" +#define JPEG_SIGNATURE_LEN 4 + +int GP_MatchJPG(const void *buf) +{ + return !memcmp(buf, JPEG_SIGNATURE, JPEG_SIGNATURE_LEN); +} + int GP_OpenJPG(const char *src_path, FILE **f) { int err; diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index ab374c4..226d388 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -36,7 +36,7 @@
#include "GP_Loader.h"
-static GP_Loader psp_image = { +static GP_Loader psp_loader = { .Load = GP_LoadPSP, .Save = NULL, .Match = GP_MatchPSP, @@ -45,8 +45,44 @@ static GP_Loader psp_image = { .extensions = {"psp", "pspimage", NULL}, };
-static GP_Loader *loaders = &psp_image; -static GP_Loader *loaders_last = &psp_image; +static GP_Loader bmp_loader = { + .Load = GP_LoadBMP, + .Save = NULL, + .Match = NULL, + .fmt_name = "BMP", + .next = &psp_loader, + .extensions = {"bmp", "dib", NULL}, +}; + +static GP_Loader gif_loader = { + .Load = GP_LoadGIF, + .Save = NULL, + .Match = GP_MatchGIF, + .fmt_name = "Graphics Interchange Format", + .next = &bmp_loader, + .extensions = {"gif", NULL}, +}; + +static GP_Loader png_loader = { + .Load = GP_LoadPNG, + .Save = GP_SavePNG, + .Match = GP_MatchPNG, + .fmt_name = "Portable Network Graphics", + .next = &gif_loader, + .extensions = {"png", NULL}, +}; + +static GP_Loader jpeg_loader = { + .Load = GP_LoadJPG, + .Save = GP_SaveJPG, + .Match = GP_MatchJPG, + .fmt_name = "JPEG", + .next = &png_loader, + .extensions = {"jpg", "jpeg", NULL}, +}; + +static GP_Loader *loaders = &jpeg_loader; +static GP_Loader *loaders_last = &psp_loader;
void GP_LoaderRegister(GP_Loader *self) { diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 7cf7441..275d4be 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -43,6 +43,11 @@
#include "core/GP_BitSwap.h"
+int GP_MatchPNG(const void *buf) +{ + return !png_sig_cmp(buf, 0, 8); +} + int GP_OpenPNG(const char *src_path, FILE **f) { uint8_t sig[8];
-----------------------------------------------------------------------
Summary of changes: include/loaders/GP_GIF.h | 5 +++++ include/loaders/GP_JPG.h | 5 +++++ include/loaders/GP_PNG.h | 5 +++++ libs/loaders/GP_GIF.c | 17 +++++++++++++++++ libs/loaders/GP_JPG.c | 12 ++++++++++++ libs/loaders/GP_Loader.c | 42 +++++++++++++++++++++++++++++++++++++++--- libs/loaders/GP_PNG.c | 5 +++++ 7 files changed, 88 insertions(+), 3 deletions(-)
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.