large.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(rowstride == 30);
  43. g_assert(width == 10);
  44. g_assert(height == 10);
  45. g_assert(pixels[0] == 188);
  46. g_assert(pixels[1] == 188);
  47. g_assert(pixels[2] == 188);
  48. g_assert(pixels[3] == 235);
  49. g_assert(pixels[4] == 235);
  50. g_assert(pixels[5] == 235);*/
  51. g_strfreev(env);
  52. g_object_unref(pixbuf);
  53. return 0;
  54. }