You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

import.c 1.5 KiB

18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * import libcaca importers test program
  3. * Copyright (c) 2006-2012 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * This program is free software. It comes without any warranty, to
  7. * the extent permitted by applicable law. You can redistribute it
  8. * and/or modify it under the terms of the Do What the Fuck You Want
  9. * to Public License, Version 2, as published by Sam Hocevar. See
  10. * http://www.wtfpl.net/ for more details.
  11. */
  12. #include "config.h"
  13. #if !defined(__KERNEL__)
  14. # include <stdio.h>
  15. # include <stdlib.h>
  16. #endif
  17. #include "caca.h"
  18. int main(int argc, char *argv[])
  19. {
  20. caca_canvas_t *cv;
  21. caca_display_t *dp;
  22. if(argc < 2)
  23. {
  24. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  25. fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
  26. return 1;
  27. }
  28. cv = caca_create_canvas(0, 0);
  29. if(cv == NULL)
  30. {
  31. printf("Can't create canvas\n");
  32. return -1;
  33. }
  34. if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
  35. {
  36. fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  37. caca_free_canvas(cv);
  38. return 1;
  39. }
  40. dp = caca_create_display(cv);
  41. if(dp == NULL)
  42. {
  43. printf("Can't create display\n");
  44. return -1;
  45. }
  46. caca_refresh_display(dp);
  47. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  48. caca_free_display(dp);
  49. caca_free_canvas(cv);
  50. return 0;
  51. }