source: libpipi/trunk/test/u8tof32tou8.c @ 2844

Last change on this file since 2844 was 2844, checked in by Sam Hocevar, 11 years ago

Fix headers.

File size: 1.6 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface 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 * loadsave.c: unit test to check that converting an image to float values
17 * and back to 8-bit integers does not change it.
18 */
19
20#include "config.h"
21#include "common.h"
22
23#include <stdio.h>
24#include <stdlib.h>
25
26#include <pipi.h>
27
28int main(int argc, char *argv[])
29{
30    pipi_image_t *img1, *img2;
31    pipi_pixels_t *pix1, *pix2;
32    uint32_t *data1, *data2;
33    int x, y, ret = EXIT_SUCCESS;
34
35    img1 = pipi_load("mona.png");
36    img2 = pipi_load("mona.png");
37
38    pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA_C);
39    data1 = (uint32_t *)pix1->pixels;
40
41    pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
42    pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA_C);
43    data2 = (uint32_t *)pix2->pixels;
44
45    for(y = 0; y < pix1->h; y++)
46    {
47        for(x = 0; x < pix1->w; x++)
48        {
49            uint32_t a = data1[y * pix1->w + x];
50            uint32_t b = data2[y * pix2->w + x];
51
52            if(a != b)
53            {
54                printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y);
55                ret = EXIT_FAILURE;
56            }
57        }
58    }
59
60    pipi_free(img1);
61    pipi_free(img2);
62
63    return ret;
64}
65
Note: See TracBrowser for help on using the repository browser.