git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2679 92316355-f0b4-4df1-b90c-862c8a59935fremotes/tiles
| @@ -22,7 +22,6 @@ int main(int argc, char *argv[]) | |||||
| dstname = argv[2]; | dstname = argv[2]; | ||||
| img = pipi_load(srcname); | img = pipi_load(srcname); | ||||
| pipi_test(img); | |||||
| pipi_save(img, dstname); | pipi_save(img, dstname); | ||||
| pipi_free(img); | pipi_free(img); | ||||
| @@ -10,11 +10,6 @@ pkgconfigdir = $(libdir)/pkgconfig | |||||
| include_HEADERS = pipi.h | include_HEADERS = pipi.h | ||||
| # Conditional sources | |||||
| codec_cflags = | |||||
| codec_libs = | |||||
| codec_sources = | |||||
| # The main library | # The main library | ||||
| lib_LTLIBRARIES = libpipi.la | lib_LTLIBRARIES = libpipi.la | ||||
| libpipi_la_SOURCES = \ | libpipi_la_SOURCES = \ | ||||
| @@ -26,20 +21,31 @@ libpipi_la_SOURCES = \ | |||||
| resize.c \ | resize.c \ | ||||
| dither.c \ | dither.c \ | ||||
| measure.c \ | measure.c \ | ||||
| test.c \ | |||||
| fill/floodfill.c \ | |||||
| $(codec_sources) \ | $(codec_sources) \ | ||||
| $(filter_sources) \ | |||||
| $(dither_sources) \ | |||||
| $(NULL) | |||||
| libpipi_la_CFLAGS = $(codec_cflags) | |||||
| libpipi_la_LDFLAGS = $(codec_libs) \ | |||||
| -no-undefined -version-number @LT_VERSION@ | |||||
| # Conditional sources | |||||
| codec_cflags = | |||||
| codec_libs = | |||||
| codec_sources = | |||||
| # Submodules | |||||
| filter_sources = \ | |||||
| filter/blur.c \ | filter/blur.c \ | ||||
| filter/convolution.c \ | |||||
| filter/convolution.c | |||||
| dither_sources = \ | |||||
| dither/floydsteinberg.c \ | dither/floydsteinberg.c \ | ||||
| dither/ordered.c \ | dither/ordered.c \ | ||||
| dither/ostromoukhov.c \ | dither/ostromoukhov.c \ | ||||
| dither/dbs.c \ | dither/dbs.c \ | ||||
| dither/random.c \ | |||||
| fill/floodfill.c \ | |||||
| $(NULL) | |||||
| libpipi_la_CFLAGS = $(codec_cflags) | |||||
| libpipi_la_LDFLAGS = $(codec_libs) \ | |||||
| -no-undefined -version-number @LT_VERSION@ | |||||
| dither/random.c | |||||
| if USE_SDL | if USE_SDL | ||||
| codec_cflags += `sdl-config --cflags` | codec_cflags += `sdl-config --cflags` | ||||
| @@ -92,8 +92,6 @@ extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t); | |||||
| extern pipi_image_t *pipi_dither_dbs(pipi_image_t *); | extern pipi_image_t *pipi_dither_dbs(pipi_image_t *); | ||||
| extern void pipi_dither_24to16(pipi_image_t *); | extern void pipi_dither_24to16(pipi_image_t *); | ||||
| extern void pipi_test(pipi_image_t *); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -1,71 +0,0 @@ | |||||
| /* | |||||
| * 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 repository 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) | |||||
| { | |||||
| pipi_pixels_t *pixels; | |||||
| float *data; | |||||
| int x, y; | |||||
| pixels = pipi_getpixels(img, PIPI_PIXELS_RGBA_F); | |||||
| data = (float *)pixels->pixels; | |||||
| for(y = 0; y < img->h; y++) | |||||
| { | |||||
| for(x = 0; x < img->w; x++) | |||||
| { | |||||
| double r = 0, g = 0, b = 0; | |||||
| r = data[(y * img->w + x) * 4]; | |||||
| g = data[(y * img->w + x) * 4 + 1]; | |||||
| b = data[(y * img->w + x) * 4 + 2]; | |||||
| 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; | |||||
| } | |||||
| data[(y * img->w + x) * 4] = r; | |||||
| data[(y * img->w + x) * 4 + 1] = g; | |||||
| data[(y * img->w + x) * 4 + 2] = b; | |||||
| } | |||||
| } | |||||
| } | |||||