Browse Source

* dither.c: add an example program for dithering methods.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2652 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
3e575ba28a
3 changed files with 53 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +4
    -1
      examples/Makefile.am
  3. +48
    -0
      examples/dither.c

+ 1
- 0
.gitignore View File

@@ -11,6 +11,7 @@ libtool
pipi/pipi.pc
genethumb/genethumb
examples/blur
examples/dither
examples/edd
examples/img2rubik
test/u8tof32tou8


+ 4
- 1
examples/Makefile.am View File

@@ -2,11 +2,14 @@

AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/pipi

bin_PROGRAMS = blur edd img2rubik
bin_PROGRAMS = blur dither edd img2rubik

blur_SOURCES = blur.c
blur_LDADD = ../pipi/libpipi.la

dither_SOURCES = dither.c
dither_LDADD = ../pipi/libpipi.la

edd_SOURCES = edd.c
edd_LDADD = ../pipi/libpipi.la



+ 48
- 0
examples/dither.c View File

@@ -0,0 +1,48 @@
#include "config.h"
#include "common.h"

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

#include <pipi.h>

int main(int argc, char *argv[])
{
char *srcname = NULL, *dstname = NULL;
pipi_image_t *img, *newimg;

if(argc < 3)
{
fprintf(stderr, "%s: too few arguments\n", argv[0]);
fprintf(stderr, "Usage: %s <src> <method> <dest>\n", argv[0]);
fprintf(stderr, "Where <method> is one of:\n");
fprintf(stderr, " 1 Floyd-Steinberg\n");
fprintf(stderr, " 2 Direct binary search\n");
return EXIT_FAILURE;
}

srcname = argv[1];
dstname = argv[3];

img = pipi_load(srcname);
pipi_getpixels(img, PIPI_PIXELS_RGBA_F);

switch(atoi(argv[2]))
{
case 2:
newimg = pipi_dbs(img); break;
case 1:
default:
newimg = pipi_floydsteinberg(img); break;
}

pipi_free(img);

pipi_getpixels(newimg, PIPI_PIXELS_RGBA_F);
pipi_save(newimg, dstname);
pipi_free(newimg);

return 0;
}


Loading…
Cancel
Save