save.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* GdkPixbuf library - JPEG2000 Image Loader
  2. *
  3. * Copyright © 2020 - 2024 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. // gdk_pixbuf_rotate_simple(pixbuf, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
  34. GdkPixbuf *flipped = gdk_pixbuf_rotate_simple(pixbuf, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE); // gdk_pixbuf_flip(pixbuf, (gboolean) TRUE);
  35. if(flipped == NULL)
  36. {
  37. g_error("Failed flipping image");
  38. }
  39. g_assert(flipped != NULL);
  40. gdk_pixbuf_save(flipped, "test_save.jp2", "jp2", &error, NULL);
  41. if(error)
  42. {
  43. g_error("%s", error->message);
  44. }
  45. g_assert(error == NULL);
  46. return 0;
  47. }