source: libcaca/trunk/examples/import.c @ 3495

Last change on this file since 3495 was 3495, checked in by Sam Hocevar, 11 years ago

Add caca_export_area_to_memory() to export only a selected part of the
current canvas. This is useful to export dirty rectangles. Accordingly,
add caca_import_area_from_memory() and caca_import_area_from_file().

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1/*
2 *  import        libcaca importers test program
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  $Id: import.c 3495 2009-05-21 20:55:21Z sam $
7 *
8 *  This program 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#include "config.h"
16
17#if !defined(__KERNEL__)
18#   include <stdio.h>
19#   include <stdlib.h>
20#endif
21
22#include "caca.h"
23
24int main(int argc, char *argv[])
25{
26    caca_canvas_t *cv;
27    caca_display_t *dp;
28
29    if(argc < 2)
30    {
31        fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
32        fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
33        return 1;
34    }
35
36    cv = caca_create_canvas(0, 0);
37    if(cv == NULL)
38    {
39        printf("Can't create canvas\n");
40        return -1;
41    }
42
43    if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
44    {
45        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
46        caca_free_canvas(cv);
47        return 1;
48    }
49
50    dp = caca_create_display(cv);
51    if(dp == NULL)
52    {
53        printf("Can't create display\n");
54        return -1;
55    }
56
57    caca_refresh_display(dp);
58
59    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
60
61    caca_free_display(dp);
62    caca_free_canvas(cv);
63
64    return 0;
65}
66
Note: See TracBrowser for help on using the repository browser.