|
|
@@ -71,6 +71,56 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...) |
|
|
|
pipi_save(ctx->images[ctx->nimages], file); |
|
|
|
pipi_free(ctx->images[ctx->nimages]); |
|
|
|
} |
|
|
|
else if(!strcmp(cmd, "dither")) |
|
|
|
{ |
|
|
|
pipi_image_t *src, *dst; |
|
|
|
char const *method; |
|
|
|
va_list ap; |
|
|
|
|
|
|
|
if(ctx->nimages <= 0) |
|
|
|
return -1; |
|
|
|
va_start(ap, cmd); |
|
|
|
method = va_arg(ap, char const *); |
|
|
|
va_end(ap); |
|
|
|
src = ctx->images[ctx->nimages - 1]; |
|
|
|
dst = NULL; |
|
|
|
if(!strcmp(method, "fs")) |
|
|
|
dst = pipi_dither_floydsteinberg(src, 0); |
|
|
|
else if(!strcmp(method, "sfs")) |
|
|
|
dst = pipi_dither_floydsteinberg(src, 1); |
|
|
|
else if(!strcmp(method, "ost")) |
|
|
|
dst = pipi_dither_ostromoukhov(src, 0); |
|
|
|
else if(!strcmp(method, "sost")) |
|
|
|
dst = pipi_dither_ostromoukhov(src, 1); |
|
|
|
else if(!strcmp(method, "ordered")) |
|
|
|
dst = pipi_dither_ordered(src); |
|
|
|
else if(!strcmp(method, "random")) |
|
|
|
dst = pipi_dither_random(src); |
|
|
|
else if(!strcmp(method, "dbs")) |
|
|
|
dst = pipi_dither_dbs(src); |
|
|
|
if(dst == NULL) |
|
|
|
return -1; |
|
|
|
pipi_free(src); |
|
|
|
ctx->images[ctx->nimages - 1] = dst; |
|
|
|
} |
|
|
|
else if(!strcmp(cmd, "blur")) |
|
|
|
{ |
|
|
|
pipi_image_t *src, *dst; |
|
|
|
char const *arg; |
|
|
|
va_list ap; |
|
|
|
|
|
|
|
if(ctx->nimages <= 0) |
|
|
|
return -1; |
|
|
|
va_start(ap, cmd); |
|
|
|
arg = va_arg(ap, char const *); |
|
|
|
va_end(ap); |
|
|
|
src = ctx->images[ctx->nimages - 1]; |
|
|
|
dst = pipi_gaussian_blur(src, atoi(arg)); |
|
|
|
if(dst == NULL) |
|
|
|
return -1; |
|
|
|
pipi_free(src); |
|
|
|
ctx->images[ctx->nimages - 1] = dst; |
|
|
|
} |
|
|
|
else if(!strcmp(cmd, "free")) |
|
|
|
{ |
|
|
|
if(ctx->nimages <= 0) |
|
|
|