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 0d68cb863abf1ed7aef032d87f21a0e7193f2986 (commit) via ce2eb53e48956d4f98fe814c10459c4340c077a9 (commit) via 056c9ac7bfef008374277b3aba84568742109d51 (commit) via 6874eb6694b57df3bc5c7d1a06688be72524e448 (commit) from cca1a95d0c61b096110045f796c86ab02703362f (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/0d68cb863abf1ed7aef032d87f21a0e7193f2...
commit 0d68cb863abf1ed7aef032d87f21a0e7193f2986 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 28 14:14:32 2012 +0200
loaders: Make use of double metadata type.
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 7602fe7..5f324aa 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -284,8 +284,8 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat double width, height;
if (png_get_sCAL(png, png_info, &unit, &width, &height)) { - GP_MetaDataCreateInt(data, "width", width * 1000); - GP_MetaDataCreateInt(data, "height", height * 1000); + GP_MetaDataCreateDouble(data, "width", width); + GP_MetaDataCreateDouble(data, "height", height); GP_MetaDataCreateInt(data, "unit", unit); }
http://repo.or.cz/w/gfxprim.git/commit/ce2eb53e48956d4f98fe814c10459c4340c07...
commit ce2eb53e48956d4f98fe814c10459c4340c077a9 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 28 14:09:07 2012 +0200
demos: Edhance png meta-data dumper example.
diff --git a/demos/c_simple/meta_data_png.c b/demos/c_simple/meta_data_png.c index 3303bed..9f6543b 100644 --- a/demos/c_simple/meta_data_png.c +++ b/demos/c_simple/meta_data_png.c @@ -32,24 +32,36 @@
#include <GP.h>
+#define SEP +"-----------------------------------------------------------------------------" + int main(int argc, char *argv[]) { - GP_MetaData *data = GP_MetaDataCreate(10); + GP_MetaData *data = GP_MetaDataCreate(20); + int i;
- if (argc != 2) { - fprintf(stderr, "Takes an image as an parametern"); + if (argc < 2) { + fprintf(stderr, "Takes an image(s) as parameter(s)n"); return 1; } //GP_SetDebugLevel(10);
- if (GP_LoadPNGMetaData(argv[1], data)) { - fprintf(stderr, "Failed to read '%s' meta-data: %sn", - argv[1], strerror(errno)); - return 1; + for (i = 1; i < argc; i++) { + puts(SEP); + printf("Opening '%s'n", argv[i]); + + GP_MetaDataClear(data); + + if (GP_LoadPNGMetaData(argv[i], data)) { + fprintf(stderr, "Failed to read '%s' meta-data: %sn", + argv[1], strerror(errno)); + } else { + GP_MetaDataPrint(data); + } } - - GP_MetaDataPrint(data); + + puts(SEP);
return 0; }
http://repo.or.cz/w/gfxprim.git/commit/056c9ac7bfef008374277b3aba84568742109...
commit 056c9ac7bfef008374277b3aba84568742109d51 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 28 14:08:47 2012 +0200
demos: Add forgotten meta_data example.
diff --git a/demos/c_simple/meta_data.c b/demos/c_simple/meta_data.c new file mode 100644 index 0000000..b5f2905 --- /dev/null +++ b/demos/c_simple/meta_data.c @@ -0,0 +1,84 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + + /* + + Meta-data storage operations example. + + Meta-data storage is used to store image meta-data (if present) such as + physical size, creation date, etc... + + Meta-data storage is basically an typed dictionary. + + This example shows low-level interface to GP_MetaData structure. + + */ + +#include <stdio.h> + +#include <GP.h> + +int main(void) +{ + GP_MetaData *data = GP_MetaDataCreate(10); + + //GP_SetDebugLevel(10); + + if (data == NULL) + return 1; + + /* + * Create integer + * + * May fail, if there is allready record with id 'dpi' or + * if there is no space left. + */ + GP_MetaDataCreateInt(data, "dpi", 300); + + /* + * Create an string. + * + * The last parameter says, if the string should be duplicated + * in the metadata storage. + */ + GP_MetaDataCreateString(data, "author", "Foo Bar foo@bar.net", 1); + GP_MetaDataCreateString(data, "comment", "Created in hurry.", 1); + GP_MetaDataCreateDouble(data, "pi", 3.141592); + + const char *ret; + + ret = GP_MetaDataGetString(data, "comment"); + + if (ret != NULL) + printf("Found string 'comment' = '%s'n", ret); + else + printf("ERROR: cannot cound string 'comment'n"); + + printf("n"); + + /* + * Print all meta-data + */ + GP_MetaDataPrint(data); + + return 0; +}
http://repo.or.cz/w/gfxprim.git/commit/6874eb6694b57df3bc5c7d1a06688be72524e...
commit 6874eb6694b57df3bc5c7d1a06688be72524e448 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 28 14:08:04 2012 +0200
loaders: Add meta-data clear method and double type.
diff --git a/include/loaders/GP_MetaData.h b/include/loaders/GP_MetaData.h index 2820ee0..4da30f1 100644 --- a/include/loaders/GP_MetaData.h +++ b/include/loaders/GP_MetaData.h @@ -28,10 +28,12 @@ enum GP_MetaType { GP_META_INT, GP_META_STRING, + GP_META_DOUBLE, };
union GP_MetaValue { int i; + double d; const char *str; };
@@ -53,6 +55,11 @@ typedef struct GP_MetaData GP_MetaData; GP_MetaData *GP_MetaDataCreate(unsigned int expected_records);
/* + * Clears meta-data storage. + */ +void GP_MetaDataClear(GP_MetaData *self); + +/* * Destroys metadata (frees all alocated memory). */ void GP_MetaDataDestroy(GP_MetaData *self); @@ -92,6 +99,12 @@ GP_MetaRecord *GP_MetaDataCreateRecord(GP_MetaData *self, const char *id); GP_MetaRecord *GP_MetaDataCreateInt(GP_MetaData *self, const char *id, int val);
/* + * Creates an double record and returns pointer to it. + */ +GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id, + double val); + +/* * Creates an string record and returns pointer to it. * * If dup is set to 1, the string is duplicated inside of the MetaData diff --git a/libs/loaders/GP_MetaData.c b/libs/loaders/GP_MetaData.c index b0fcdf8..e62af18 100644 --- a/libs/loaders/GP_MetaData.c +++ b/libs/loaders/GP_MetaData.c @@ -70,6 +70,16 @@ GP_MetaData *GP_MetaDataCreate(unsigned int expected_records) return data; }
+void GP_MetaDataClear(GP_MetaData *self) +{ + GP_DEBUG(1, "Clearing MetaData %p with %u records", + self, self->rec_count); + + self->root = NULL; + self->rec_count = 0; + self->free = self->size; +} + void GP_MetaDataDestroy(GP_MetaData *self) { GP_DEBUG(1, "Destroying MetaData %p", self); @@ -92,6 +102,9 @@ void GP_MetaDataPrint(GP_MetaData *self) case GP_META_STRING: printf("'%s'n", rec->val.str); break; + case GP_META_DOUBLE: + printf("%lfn", rec->val.d); + break; } } } @@ -185,6 +198,31 @@ int GP_MetaDataGetInt(GP_MetaData *self, const char *id, int *res) return 0; }
+int GP_MetaDataGetDouble(GP_MetaData *self, const char *id, double *res) +{ + GP_MetaRecord *rec; + + GP_DEBUG(2, "Looking for GP_META_DOUBLE id '%s'", id); + + rec = record_lookup(self, id, do_hash(id)); + + if (rec == NULL) { + GP_DEBUG(3, "Record id '%s' not found", id); + return 1; + } + + if (rec->type != GP_META_DOUBLE) { + GP_DEBUG(3, "Record id '%s' has wrong type", id); + return 1; + } + + *res = rec->val.d; + + GP_DEBUG(3, "Found GP_META_DOUBLE id '%s' = %lf", id, *res); + + return 0; +} + const char *GP_MetaDataGetString(GP_MetaData *self, const char *id) { GP_MetaRecord *rec; @@ -225,6 +263,24 @@ GP_MetaRecord *GP_MetaDataCreateInt(GP_MetaData *self, const char *id, int val) return rec; }
+GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id, + double val) +{ + GP_MetaRecord *rec; + + GP_DEBUG(2, "Creating GP_META_DOUBLE id '%s' = %lf", id, val); + + rec = GP_MetaDataCreateRecord(self, id); + + if (rec == NULL) + return NULL; + + rec->type = GP_META_DOUBLE; + rec->val.d = val; + + return rec; +} + GP_MetaRecord *GP_MetaDataCreateString(GP_MetaData *self, const char *id, const char *str, int dup) {
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/{meta_data_png.c => meta_data.c} | 55 +++++++++++++++++----- demos/c_simple/meta_data_png.c | 30 +++++++++---- include/loaders/GP_MetaData.h | 13 +++++ libs/loaders/GP_MetaData.c | 56 +++++++++++++++++++++++ libs/loaders/GP_PNG.c | 4 +- 5 files changed, 134 insertions(+), 24 deletions(-) copy demos/c_simple/{meta_data_png.c => meta_data.c} (63%)
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.