Quellcode durchsuchen

* Add functions that handle a stack-based processing queue.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2692 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam vor 16 Jahren
Ursprung
Commit
0f3943d0fe
4 geänderte Dateien mit 109 neuen und 0 gelöschten Zeilen
  1. +1
    -0
      pipi/Makefile.am
  2. +95
    -0
      pipi/context.c
  3. +7
    -0
      pipi/pipi.h
  4. +6
    -0
      pipi/pipi_internals.h

+ 1
- 0
pipi/Makefile.am Datei anzeigen

@@ -16,6 +16,7 @@ libpipi_la_SOURCES = \
pipi.c \
pipi.h \
pipi_internals.h \
context.c \
pixels.c \
codec.c \
resize.c \


+ 95
- 0
pipi/context.c Datei anzeigen

@@ -0,0 +1,95 @@
/*
* libpipi Proper image processing implementation library
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* context.c: processing stack handling routines
*/

#include "config.h"
#include "common.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#include "pipi.h"
#include "pipi_internals.h"

pipi_context_t *pipi_create_context()
{
pipi_context_t *ret;

ret = malloc(sizeof(pipi_context_t));
memset(ret, 0, sizeof(pipi_context_t));

return ret;
}

void pipi_destroy_context(pipi_context_t *ctx)
{
free(ctx);
}

int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
{
if(!strcmp(cmd, "load"))
{
char const *file;
va_list ap;

va_start(ap, cmd);
file = va_arg(ap, char const *);
va_end(ap);
ctx->images[ctx->nimages] = pipi_load(file);
if(ctx->images[ctx->nimages] == NULL)
return -1;
ctx->nimages++;
}
else if(!strcmp(cmd, "save"))
{
char const *file;
va_list ap;

if(ctx->nimages <= 0)
return -1;
ctx->nimages--;
va_start(ap, cmd);
file = va_arg(ap, char const *);
va_end(ap);
pipi_save(ctx->images[ctx->nimages], file);
pipi_free(ctx->images[ctx->nimages]);
}
else if(!strcmp(cmd, "free"))
{
if(ctx->nimages <= 0)
return -1;
ctx->nimages--;
pipi_free(ctx->images[ctx->nimages]);
}
else if(!strcmp(cmd, "dup"))
{
if(ctx->nimages <= 0)
return -1;
ctx->images[ctx->nimages] = pipi_copy(ctx->images[ctx->nimages - 1]);
ctx->nimages++;
}
else
{
return -1;
}

return 0;
}


+ 7
- 0
pipi/pipi.h Datei anzeigen

@@ -63,6 +63,13 @@ pipi_pixels_t;
/* pipi_image_t: the main image type */
typedef struct pipi_image pipi_image_t;

/* pipi_context_t: the processing stack */
typedef struct pipi_context pipi_context_t;


extern pipi_context_t *pipi_create_context(void);
extern void pipi_destroy_context(pipi_context_t *);
extern int pipi_command(pipi_context_t *, char const *, ...);

extern pipi_image_t *pipi_load(const char *);
extern pipi_image_t *pipi_new(int, int);


+ 6
- 0
pipi/pipi_internals.h Datei anzeigen

@@ -34,6 +34,12 @@ struct pipi_image
void *codec_priv;
};

struct pipi_context
{
int nimages;
pipi_image_t *images[1024]; /* FIXME: do dynamic allocation */
};

#ifdef USE_IMLIB2
pipi_image_t *pipi_load_imlib2(const char *name);
pipi_image_t *pipi_new_imlib2(int width, int height);


Laden…
Abbrechen
Speichern