diff --git a/pipi/Makefile.am b/pipi/Makefile.am index 8945743..db47c93 100644 --- a/pipi/Makefile.am +++ b/pipi/Makefile.am @@ -59,6 +59,7 @@ render_sources = \ render/screen.c combine_sources = \ + combine/blit.c \ combine/rgb.c \ combine/merge.c \ combine/minmax.c \ diff --git a/pipi/context.c b/pipi/context.c index b31b683..c24a318 100644 --- a/pipi/context.c +++ b/pipi/context.c @@ -79,6 +79,7 @@ pipi_command_t const *pipi_get_command_list(void) { "wrap", 0 }, { "combine", 0 }, { "split", 0 }, + { "blit", 1 }, { "mean", 0 }, { "merge", 1 }, { "min", 0 }, @@ -461,6 +462,33 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...) ctx->images[ctx->nimages - 3] = dst; ctx->nimages -= 2; } + else if(!strcmp(cmd, "blit")) + { + pipi_image_t *dst; + char const *arg; + va_list ap; + int x, y; + + if(ctx->nimages < 2) + return -1; + va_start(ap, cmd); + arg = va_arg(ap, char const *); + va_end(ap); + x = atoi(arg); + arg = strchr(arg, 'x'); + if(!arg) + return -1; + y = atoi(arg + 1); + + dst = pipi_blit(ctx->images[ctx->nimages - 2], + ctx->images[ctx->nimages - 1], x, y); + if(dst == NULL) + return -1; + pipi_free(ctx->images[ctx->nimages - 2]); + pipi_free(ctx->images[ctx->nimages - 1]); + ctx->images[ctx->nimages - 2] = dst; + ctx->nimages--; + } else if(!strcmp(cmd, "merge")) { pipi_image_t *dst; diff --git a/pipi/pipi.h b/pipi/pipi.h index f2cb306..6db0327 100644 --- a/pipi/pipi.h +++ b/pipi/pipi.h @@ -167,6 +167,7 @@ __extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *); __extern pipi_image_t *pipi_red(pipi_image_t *); __extern pipi_image_t *pipi_green(pipi_image_t *); __extern pipi_image_t *pipi_blue(pipi_image_t *); +__extern pipi_image_t *pipi_blit(pipi_image_t *, pipi_image_t *, int, int); __extern pipi_image_t *pipi_merge(pipi_image_t *, pipi_image_t *, double); __extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *); __extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);