From 15bd1837435f64f6b33300db718fe6f02a73d9ee Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 23 Aug 2008 09:11:20 +0000 Subject: [PATCH] * Rename --rgb into --combine and add --split. Basic per-channel operations are now possible: pipi src.png --split --contrast -.2 --combine -o dest.png git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2755 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/context.c | 15 ++++++++++++++- src/pipi.c | 9 +++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pipi/context.c b/pipi/context.c index e04c59a..0435d06 100644 --- a/pipi/context.c +++ b/pipi/context.c @@ -373,7 +373,20 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...) ctx->images[ctx->nimages - 1] = pipi_rotate270(tmp); pipi_free(tmp); } - else if(!strcmp(cmd, "rgb")) + else if(!strcmp(cmd, "split")) + { + pipi_image_t *src; + + if(ctx->nimages < 1) + return -1; + src = ctx->images[ctx->nimages - 1]; + ctx->nimages += 2; + ctx->images[ctx->nimages - 3] = pipi_red(src); + ctx->images[ctx->nimages - 2] = pipi_green(src); + ctx->images[ctx->nimages - 1] = pipi_blue(src); + pipi_free(src); + } + else if(!strcmp(cmd, "combine")) { pipi_image_t *dst; diff --git a/src/pipi.c b/src/pipi.c index 986f1b8..fabde16 100644 --- a/src/pipi.c +++ b/src/pipi.c @@ -168,9 +168,14 @@ int main(int argc, char *argv[]) if(pipi_command(ctx, "wrap") != 0) return EXIT_FAILURE; } - else if(!strcmp(argv[0], "--rgb")) + else if(!strcmp(argv[0], "--combine")) { - if(pipi_command(ctx, "rgb") != 0) + if(pipi_command(ctx, "combine") != 0) + return EXIT_FAILURE; + } + else if(!strcmp(argv[0], "--split")) + { + if(pipi_command(ctx, "split") != 0) return EXIT_FAILURE; } else if(!strcmp(argv[0], "--mean"))