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 eb4a525b020632bd5011f14ff9f759eef926dee2 (commit) from acea12e66ecb83f34fd19be737bddd0c289bf584 (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/eb4a525b020632bd5011f14ff9f759eef926d...
commit eb4a525b020632bd5011f14ff9f759eef926dee2 Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 20 12:34:01 2011 +0100
grinder: Add filters to save JPG/PNG.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 858b2a6..6f86e69 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -370,6 +370,7 @@ static const char *dither_formats[] = { "rgb333", "rgb565", "rgb666", + NULL, };
static const GP_PixelType dither_pixel_types[] = { @@ -413,6 +414,54 @@ static GP_RetCode dither(GP_Context **c, const char *params) return GP_ESUCCESS; }
+/* jpg save filter */ + +static struct param save_jpg_params[] = { + {"file", PARAM_STR, "Filename to save the result", NULL, NULL}, + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode save_jpg(GP_Context **c, const char *params) +{ + char *file = NULL; + + if (param_parse(params, save_jpg_params, "jpg", param_err, &file)) + return GP_EINVAL; + + if (file == NULL) { + print_error("jpg: filename missing"); + return GP_EINVAL; + } + + GP_SaveJPG(file, *c, progress_callback); + + return GP_ESUCCESS; +} + +/* png save filter */ + +static struct param save_png_params[] = { + {"file", PARAM_STR, "Filename to save the result", NULL, NULL}, + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode save_png(GP_Context **c, const char *params) +{ + char *file = NULL; + + if (param_parse(params, save_png_params, "png", param_err, &file)) + return GP_EINVAL; + + if (file == NULL) { + print_error("png: filename missing"); + return GP_EINVAL; + } + + GP_SavePNG(file, *c, progress_callback); + + return GP_ESUCCESS; +} + /* filters */
struct filter { @@ -432,6 +481,8 @@ static struct filter filter_table[] = { {"invert", "inverts image", invert_params, invert}, {"blur", "gaussian blur", blur_params, blur}, {"dither", "dithers bitmap", dither_params, dither}, + {"jpg", "save jpg image", save_jpg_params, save_jpg}, + {"png", "save png image", save_png_params, save_png}, {NULL, NULL, NULL, NULL} };
diff --git a/demos/grinder/params.c b/demos/grinder/params.c index 2734980..6d2b1aa 100644 --- a/demos/grinder/params.c +++ b/demos/grinder/params.c @@ -248,6 +248,12 @@ int set_enum(int *res, char *val, const char *enums[]) return 1; }
+int set_str(char **res, char *val) +{ + *res = val; + return 0; +} + #define CALL_ERR_CALLBACK(error, p, value, private) do { int error_ret; @@ -323,7 +329,11 @@ int param_parse(const char *params, const struct param *param_desc, void *priv, } break; case PARAM_STR: - + if ((ret = set_str(arg, values[pos]))) { + CALL_ERR_CALLBACK(err, ¶m_desc[i], + values[pos], priv); + goto err; + } break; case PARAM_ENUM: if ((ret = set_enum(arg, values[pos],
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ demos/grinder/params.c | 12 ++++++++++- 2 files changed, 62 insertions(+), 1 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.