Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

u8tof32tou8.c 1.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * 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 <stdio.h>
  20. #include <stdlib.h>
  21. #include <pipi.h>
  22. int main(int argc, char *argv[])
  23. {
  24. pipi_image_t *img1, *img2;
  25. pipi_pixels_t *pix1, *pix2;
  26. uint32_t *data1, *data2;
  27. int x, y, ret = EXIT_SUCCESS;
  28. img1 = pipi_load("mona.png");
  29. img2 = pipi_load("mona.png");
  30. pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA_C);
  31. data1 = (uint32_t *)pix1->pixels;
  32. pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
  33. pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA_C);
  34. data2 = (uint32_t *)pix2->pixels;
  35. for(y = 0; y < pix1->h; y++)
  36. {
  37. for(x = 0; x < pix1->w; x++)
  38. {
  39. uint32_t a = data1[y * pix1->w + x];
  40. uint32_t b = data2[y * pix2->w + x];
  41. if(a != b)
  42. {
  43. printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y);
  44. ret = EXIT_FAILURE;
  45. }
  46. }
  47. }
  48. pipi_free(img1);
  49. pipi_free(img2);
  50. return ret;
  51. }