Procházet zdrojové kódy

* Add pipi_tile, to create image mosaics.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2717 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam před 16 roky
rodič
revize
48b881b6fa
6 změnil soubory, kde provedl 95 přidání a 1 odebrání
  1. +5
    -1
      pipi/Makefile.am
  2. +26
    -0
      pipi/context.c
  3. +0
    -0
      pipi/paint/floodfill.c
  4. +55
    -0
      pipi/paint/tile.c
  5. +1
    -0
      pipi/pipi.h
  6. +8
    -0
      src/pipi.c

+ 5
- 1
pipi/Makefile.am Zobrazit soubor

@@ -23,8 +23,8 @@ libpipi_la_SOURCES = \
resize.c \
dither.c \
measure.c \
fill/floodfill.c \
$(codec_sources) \
$(paint_sources) \
$(combine_sources) \
$(filter_sources) \
$(dither_sources) \
@@ -39,6 +39,10 @@ codec_libs =
codec_sources =

# Submodules
paint_sources = \
paint/floodfill.c \
paint/tile.c

combine_sources = \
combine/mean.c \
combine/minmax.c \


+ 26
- 0
pipi/context.c Zobrazit soubor

@@ -167,6 +167,32 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
pipi_free(src);
ctx->images[ctx->nimages - 1] = dst;
}
else if(!strcmp(cmd, "tile"))
{
pipi_image_t *src, *dst;
char const *arg;
va_list ap;
int w, h;

if(ctx->nimages < 1)
return -1;
va_start(ap, cmd);
arg = va_arg(ap, char const *);
va_end(ap);
w = atoi(arg);
arg = strchr(arg, 'x');
if(!arg)
return -1;
h = atoi(arg + 1);
if(w <= 0 || h <= 0)
return -1;
src = ctx->images[ctx->nimages - 1];
dst = pipi_tile(src, w, h);
if(dst == NULL)
return -1;
pipi_free(src);
ctx->images[ctx->nimages - 1] = dst;
}
else if(!strcmp(cmd, "scale"))
{
pipi_image_t *src, *dst;


pipi/fill/floodfill.c → pipi/paint/floodfill.c Zobrazit soubor


+ 55
- 0
pipi/paint/tile.c Zobrazit soubor

@@ -0,0 +1,55 @@
/*
* 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.
*/

/*
* tile.c: Tiling function
*/

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

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

pipi_image_t *pipi_tile(pipi_image_t *tile, int w, int h)
{
pipi_image_t *dst;
pipi_pixels_t *tilep, *dstp;
float *tiledata, *dstdata;
int x, y, tw, th, todo;

tw = tile->w;
th = tile->h;

dst = pipi_new(w, h);
dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA_F);
dstdata = (float *)dstp->pixels;

tilep = pipi_getpixels(tile, PIPI_PIXELS_RGBA_F);
tiledata = (float *)tilep->pixels;

for(y = 0; y < h; y++)
{
for(x = 0; x < w; x += todo)
{
todo = (x + tw > w) ? w - x : tw;
memcpy(dstdata + 4 * (y * w + x),
tiledata + 4 * (y % th) * tw,
4 * todo * sizeof(float));
}
}

return dst;
}


+ 1
- 0
pipi/pipi.h Zobrazit soubor

@@ -104,6 +104,7 @@ extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
extern pipi_image_t *pipi_autocontrast(pipi_image_t *);

extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
extern int pipi_flood_fill(pipi_image_t *,
int, int, float, float, float, float);



+ 8
- 0
src/pipi.c Zobrazit soubor

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


Načítá se…
Zrušit
Uložit