Browse Source

* Checking in an old Rubik's cube dithering test.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2262 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 17 years ago
parent
commit
735b2a5da0
8 changed files with 106 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      Makefile.am
  3. +1
    -0
      configure.ac
  4. +9
    -0
      examples/Makefile.am
  5. +31
    -0
      examples/img2rubik.c
  6. +1
    -0
      pipi/Makefile.am
  7. +2
    -0
      pipi/pipi.h
  8. +60
    -0
      pipi/test.c

+ 1
- 0
.gitignore View File

@@ -10,6 +10,7 @@ Makefile
libtool
pipi/pipi.pc
genethumb/genethumb
examples/img2rubik
stamp-h1
.auto
.deps


+ 1
- 1
Makefile.am View File

@@ -1,6 +1,6 @@
# $Id$

SUBDIRS = pipi genethumb
SUBDIRS = pipi genethumb examples

EXTRA_DIST = bootstrap common.h
AUTOMAKE_OPTIONS = dist-bzip2


+ 1
- 0
configure.ac View File

@@ -108,6 +108,7 @@ AC_CONFIG_FILES([
Makefile
pipi/Makefile
genethumb/Makefile
examples/Makefile
])
AC_CONFIG_FILES([
pipi/pipi.pc


+ 9
- 0
examples/Makefile.am View File

@@ -0,0 +1,9 @@
# $Id$

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

bin_PROGRAMS = img2rubik

img2rubik_SOURCES = img2rubik.c
img2rubik_LDADD = ../pipi/libpipi.la


+ 31
- 0
examples/img2rubik.c View File

@@ -0,0 +1,31 @@
#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;

if(argc < 3)
{
fprintf(stderr, "%s: too few arguments\n", argv[0]);
return EXIT_FAILURE;
}

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

img = pipi_load(srcname);
pipi_test(img);
pipi_save(img, dstname);
pipi_free(img);

return 0;
}


+ 1
- 0
pipi/Makefile.am View File

@@ -24,6 +24,7 @@ libpipi_la_SOURCES = \
pixels.c \
codec.c \
resize.c \
test.c \
$(codec_sources) \
$(NULL)
libpipi_la_CFLAGS = $(codec_cflags)


+ 2
- 0
pipi/pipi.h View File

@@ -40,6 +40,8 @@ extern int pipi_setpixel(pipi_image_t *img, int x, int y,

extern pipi_image_t *pipi_resize(pipi_image_t const *, int, int);

extern void pipi_test(pipi_image_t *);

#ifdef __cplusplus
}
#endif


+ 60
- 0
pipi/test.c View File

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

/*
* test.c: my repostiroy of test functions
*/

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

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

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

void pipi_test(pipi_image_t *img)
{
int x, y;

for(y = 0; y < img->height; y++)
{
for(x = 0; x < img->width; x++)
{
double r = 0, g = 0, b = 0;

pipi_getpixel(img, x, y, &r, &g, &b);
if(r + g + b == 0)
r = g = b = 1. / 3;
else if(r + g + b < 1.)
{
double d = (1. - r - g - b) / 3;
r += d; g += d; b += d;
}
else if(2. - r + g - b < 1.)
{
double d = (-1. + r - g + b) / 3;
r -= d; g += d; b -= d;
}
else if(2. + r - g - b < 1.)
{
double d = (-1. - r + g + b) / 3;
r += d; g -= d; b -= d;
}
pipi_setpixel(img, x, y, r, g, b);
}
}
}


Loading…
Cancel
Save