git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2262 92316355-f0b4-4df1-b90c-862c8a59935fremotes/tiles
| @@ -10,6 +10,7 @@ Makefile | |||||
| libtool | libtool | ||||
| pipi/pipi.pc | pipi/pipi.pc | ||||
| genethumb/genethumb | genethumb/genethumb | ||||
| examples/img2rubik | |||||
| stamp-h1 | stamp-h1 | ||||
| .auto | .auto | ||||
| .deps | .deps | ||||
| @@ -1,6 +1,6 @@ | |||||
| # $Id$ | # $Id$ | ||||
| SUBDIRS = pipi genethumb | |||||
| SUBDIRS = pipi genethumb examples | |||||
| EXTRA_DIST = bootstrap common.h | EXTRA_DIST = bootstrap common.h | ||||
| AUTOMAKE_OPTIONS = dist-bzip2 | AUTOMAKE_OPTIONS = dist-bzip2 | ||||
| @@ -108,6 +108,7 @@ AC_CONFIG_FILES([ | |||||
| Makefile | Makefile | ||||
| pipi/Makefile | pipi/Makefile | ||||
| genethumb/Makefile | genethumb/Makefile | ||||
| examples/Makefile | |||||
| ]) | ]) | ||||
| AC_CONFIG_FILES([ | AC_CONFIG_FILES([ | ||||
| pipi/pipi.pc | pipi/pipi.pc | ||||
| @@ -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 | |||||
| @@ -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; | |||||
| } | |||||
| @@ -24,6 +24,7 @@ libpipi_la_SOURCES = \ | |||||
| pixels.c \ | pixels.c \ | ||||
| codec.c \ | codec.c \ | ||||
| resize.c \ | resize.c \ | ||||
| test.c \ | |||||
| $(codec_sources) \ | $(codec_sources) \ | ||||
| $(NULL) | $(NULL) | ||||
| libpipi_la_CFLAGS = $(codec_cflags) | libpipi_la_CFLAGS = $(codec_cflags) | ||||
| @@ -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 pipi_image_t *pipi_resize(pipi_image_t const *, int, int); | ||||
| extern void pipi_test(pipi_image_t *); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -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); | |||||
| } | |||||
| } | |||||
| } | |||||