/* * libpipi Pathetic image processing interface 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. */ /* * loadsave.c: unit test to check that converting an image to float values * and back to 8-bit integers does not change it. */ #include "config.h" #include #include #include int main(int argc, char *argv[]) { pipi_image_t *img1, *img2; pipi_pixels_t *pix1, *pix2; uint32_t *data1, *data2; int x, y, ret = EXIT_SUCCESS; img1 = pipi_load("mona.png"); img2 = pipi_load("mona.png"); pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA_C); data1 = (uint32_t *)pix1->pixels; pipi_getpixels(img2, PIPI_PIXELS_RGBA_F); pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA_C); data2 = (uint32_t *)pix2->pixels; for(y = 0; y < pix1->h; y++) { for(x = 0; x < pix1->w; x++) { uint32_t a = data1[y * pix1->w + x]; uint32_t b = data2[y * pix2->w + x]; if(a != b) { printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y); ret = EXIT_FAILURE; } } } pipi_free(img1); pipi_free(img2); return ret; }