Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

66 righe
1.6 KiB

  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. * loadsave.c: unit test to check that converting an image to float values
  16. * and back to 8-bit integers does not change it.
  17. */
  18. #include "config.h"
  19. #include "common.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <pipi.h>
  23. int main(int argc, char *argv[])
  24. {
  25. pipi_image_t *img1, *img2;
  26. pipi_pixels_t *pix1, *pix2;
  27. uint32_t *data1, *data2;
  28. int x, y, ret = EXIT_SUCCESS;
  29. img1 = pipi_load("mona.png");
  30. img2 = pipi_load("mona.png");
  31. pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA32);
  32. data1 = (uint32_t *)pix1->pixels;
  33. pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
  34. pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA32);
  35. data2 = (uint32_t *)pix2->pixels;
  36. for(y = 0; y < pix1->h; y++)
  37. {
  38. for(x = 0; x < pix1->w; x++)
  39. {
  40. uint32_t a = data1[y * pix1->w + x];
  41. uint32_t b = data2[y * pix2->w + x];
  42. if(a != b)
  43. {
  44. printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y);
  45. ret = EXIT_FAILURE;
  46. }
  47. }
  48. }
  49. pipi_free(img1);
  50. pipi_free(img2);
  51. return ret;
  52. }