/* * libpipi Proper image processing implementation library * Copyright (c) 2004-2008 Sam Hocevar * 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 #include #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); } } }