瀏覽代碼

* context.c: add the "swap" command to swap two images in the stack.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2709 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 年之前
父節點
當前提交
b089bc14b6
共有 2 個文件被更改,包括 22 次插入8 次删除
  1. +17
    -8
      pipi/context.c
  2. +5
    -0
      src/pipi.c

+ 17
- 8
pipi/context.c 查看文件

@@ -62,7 +62,7 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
char const *file;
va_list ap;

if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
ctx->nimages--;
va_start(ap, cmd);
@@ -77,7 +77,7 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
char const *method;
va_list ap;

if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
va_start(ap, cmd);
method = va_arg(ap, char const *);
@@ -119,7 +119,7 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
char const *arg;
va_list ap;

if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
va_start(ap, cmd);
arg = va_arg(ap, char const *);
@@ -208,14 +208,14 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
}
else if(!strcmp(cmd, "wrap"))
{
if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
ctx->images[ctx->nimages - 1]->wrap = 1;
}
else if(!strcmp(cmd, "autocontrast"))
{
pipi_image_t *tmp;
if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
tmp = ctx->images[ctx->nimages - 1];
ctx->images[ctx->nimages - 1] = pipi_autocontrast(tmp);
@@ -223,24 +223,33 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
}
else if(!strcmp(cmd, "gray"))
{
if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
pipi_getpixels(ctx->images[ctx->nimages - 1], PIPI_PIXELS_Y_F);
}
else if(!strcmp(cmd, "free"))
{
if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
ctx->nimages--;
pipi_free(ctx->images[ctx->nimages]);
}
else if(!strcmp(cmd, "dup"))
{
if(ctx->nimages <= 0)
if(ctx->nimages < 1)
return -1;
ctx->images[ctx->nimages] = pipi_copy(ctx->images[ctx->nimages - 1]);
ctx->nimages++;
}
else if(!strcmp(cmd, "swap"))
{
pipi_image_t *tmp;
if(ctx->nimages < 2)
return -1;
tmp = ctx->images[ctx->nimages - 1];
ctx->images[ctx->nimages - 1] = ctx->images[ctx->nimages - 2];
ctx->images[ctx->nimages - 2] = tmp;
}
else
{
return -1;


+ 5
- 0
src/pipi.c 查看文件

@@ -20,6 +20,11 @@ int main(int argc, char *argv[])
if(pipi_command(ctx, "dup") != 0)
return EXIT_FAILURE;
}
else if(!strcmp(argv[0], "--swap"))
{
if(pipi_command(ctx, "swap") != 0)
return EXIT_FAILURE;
}
else if(!strcmp(argv[0], "--dither"))
{
if(argv[1] == NULL)


Loading…
取消
儲存