relax.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* GdkPixbuf library - JPEG2000 Image Loader
  2. *
  3. * Copyright © 2020 Nichlas Severinsen
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <gdk-pixbuf/gdk-pixbuf.h>
  20. gint main(gint argc, gchar **argv)
  21. {
  22. int width, height, rowstride, components;
  23. guchar *pixels;
  24. GError *error = NULL;
  25. gchar **env = g_get_environ();
  26. g_warning("%s", g_environ_getenv(env, "TEST_FILE"));
  27. GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(g_environ_getenv(env, "TEST_FILE"), &error);
  28. if(error)
  29. {
  30. g_error("%s", error->message);
  31. }
  32. g_assert(error == NULL);
  33. width = gdk_pixbuf_get_width(pixbuf);
  34. height = gdk_pixbuf_get_height(pixbuf);
  35. rowstride = gdk_pixbuf_get_rowstride(pixbuf);
  36. components = gdk_pixbuf_get_n_channels (pixbuf);
  37. pixels = gdk_pixbuf_get_pixels(pixbuf);
  38. g_assert(gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB);
  39. g_assert(gdk_pixbuf_get_bits_per_sample(pixbuf) == 8);
  40. g_assert(!gdk_pixbuf_get_has_alpha(pixbuf));
  41. g_assert(components == 3);
  42. g_assert(width == 400);
  43. g_assert(height == 300);
  44. g_assert(rowstride == 1200);
  45. g_assert(pixels[0] == 51);
  46. g_assert(pixels[1] == 58);
  47. g_assert(pixels[2] == 49);
  48. g_strfreev(env);
  49. g_object_unref(pixbuf);
  50. return 0;
  51. }