source: libcaca/trunk/test/text.c @ 1753

Last change on this file since 1753 was 1753, checked in by Jean-Yves Lamoureux, 15 years ago
  • Added error checks on canvas / display creations
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/*
2 *  text          canvas text import/export
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: text.c 1753 2007-02-22 15:31:39Z jylam $
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#include "common.h"
17#if !defined(__KERNEL__)
18#   if defined(HAVE_INTTYPES_H)
19#      include <inttypes.h>
20#   endif
21#   include <stdio.h>
22#   include <string.h>
23#   include <stdlib.h>
24#endif
25#include "cucul.h"
26
27#define STRING \
28  "  _,----._  \n" \
29  " (/ @  @ \\) \n" \
30  "  |  OO  |  \n" \
31  "  \\ `--' /  \n" \
32  "   `----'   \n" \
33  "Hello world!\n"
34
35int main(int argc, char *argv[])
36{
37    cucul_canvas_t *cv, *pig;
38    void *buffer;
39    unsigned long int len;
40
41    pig = cucul_create_canvas(0, 0);
42    cucul_import_memory(pig, STRING, strlen(STRING), "text");
43
44    cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
45                             cucul_get_canvas_height(pig) * 2);
46
47    if(cv == NULL || pig == NULL)
48    {
49        printf("Can't created canvas\n");
50        return -1;
51    }
52
53    cucul_blit(cv, 0, 0, pig, NULL);
54    cucul_flip(pig);
55    cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
56    cucul_flip(pig);
57    cucul_flop(pig);
58    cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
59    cucul_flop(pig);
60    cucul_rotate(pig);
61    cucul_blit(cv, cucul_get_canvas_width(pig),
62                   cucul_get_canvas_height(pig), pig, NULL);
63
64    buffer = cucul_export_memory(cv, "utf8", &len);
65    fwrite(buffer, len, 1, stdout);
66    free(buffer);
67
68    cucul_free_canvas(pig);
69    cucul_free_canvas(cv);
70
71    return 0;
72}
73
Note: See TracBrowser for help on using the repository browser.