source: libpipi/trunk/pipi/test.c @ 2440

Last change on this file since 2440 was 2262, checked in by Sam Hocevar, 15 years ago
  • Checking in an old Rubik's cube dithering test.
File size: 1.5 KB
Line 
1/*
2 *  libpipi       Proper image processing implementation library
3 *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id$
7 *
8 *  This library is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/*
16 * test.c: my repostiroy of test functions
17 */
18
19#include "config.h"
20#include "common.h"
21
22#include <stdlib.h>
23#include <string.h>
24
25#include "pipi.h"
26#include "pipi_internals.h"
27
28void pipi_test(pipi_image_t *img)
29{
30    int x, y;
31
32    for(y = 0; y < img->height; y++)
33    {
34        for(x = 0; x < img->width; x++)
35        {
36            double r = 0, g = 0, b = 0;
37
38            pipi_getpixel(img, x, y, &r, &g, &b);
39            if(r + g + b == 0)
40                r = g = b = 1. / 3;
41            else if(r + g + b < 1.)
42            {
43                double d = (1. - r - g - b) / 3;
44                r += d; g += d; b += d;
45            }
46            else if(2. - r + g - b < 1.)
47            {
48                double d = (-1. + r - g + b) / 3;
49                r -= d; g += d; b -= d;
50            }
51            else if(2. + r - g - b < 1.)
52            {
53                double d = (-1. - r + g + b) / 3;
54                r += d; g -= d; b -= d;
55            }
56            pipi_setpixel(img, x, y, r, g, b);
57        }
58    }
59}
60
Note: See TracBrowser for help on using the repository browser.