Changeset 767 for libcaca/trunk/test
- Timestamp:
- Apr 13, 2006, 7:54:07 PM (15 years ago)
- Location:
- libcaca/trunk/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/test/Makefile.am
r750 r767 21 21 22 22 font_SOURCES = font.c 23 font_LDADD = ../c ucul/libcucul.la @CUCUL_LIBS@23 font_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@ 24 24 25 25 gamma_SOURCES = gamma.c -
libcaca/trunk/test/font.c
r763 r767 22 22 #endif 23 23 24 #if defined(HAVE_ENDIAN_H) 25 # include <endian.h> 26 #endif 27 24 28 #include <stdio.h> 25 29 #include <stdlib.h> … … 27 31 28 32 #include "cucul.h" 33 #include "caca.h" 29 34 30 35 int main(int argc, char *argv[]) 31 36 { 32 37 cucul_t *qq; 38 caca_t *kk; 33 39 struct cucul_font *f; 40 struct cucul_dither *d; 41 struct caca_event ev; 34 42 unsigned char *buf; 35 unsigned int x, y,w, h;43 unsigned int w, h; 36 44 char const * const * fonts; 37 45 … … 41 49 /* Draw stuff on our canvas */ 42 50 cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK); 43 cucul_putstr(qq, 0, 0, "ABcde\\o/"); 44 cucul_putstr(qq, 0, 1, "&$âøÿ░▒█"); 51 cucul_putstr(qq, 0, 0, "ABcde"); 52 cucul_set_color(qq, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK); 53 cucul_putstr(qq, 5, 0, "\\o/"); 54 cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); 55 cucul_putstr(qq, 0, 1, "&$âøÿØ?!"); 45 56 46 57 /* Load a libcucul internal font */ … … 52 63 } 53 64 f = cucul_load_font(fonts[0], 0); 65 if(f == NULL) 66 { 67 fprintf(stderr, "error: could not load font \"%s\"\n", fonts[0]); 68 return -1; 69 } 54 70 55 71 /* Create our bitmap buffer (32-bit ARGB) */ … … 61 77 cucul_render_canvas(qq, f, buf, w, h, 4 * w); 62 78 63 /* Just for fun, output the image on the terminal using ASCII art */ 64 for(y = 0; y < h; y++) 65 { 66 for(x = 0; x < w; x++) 67 { 68 static const char list[] = { 69 ' ', '.', ':', 't', 'S', 'R', '#', '@' 70 }; 79 /* Just for fun, render the image using libcaca */ 80 cucul_set_size(qq, 80, 32); 81 kk = caca_attach(qq); 71 82 72 printf("%c", list[buf[4 * (y * w + x) + 3] / 0x20]); 73 } 74 printf("\n"); 75 } 83 #if defined(HAVE_ENDIAN_H) 84 if(__BYTE_ORDER == __BIG_ENDIAN) 85 #else 86 /* This is compile-time optimised with at least -O1 or -Os */ 87 uint32_t const rmask = 0x12345678; 88 if(*(uint8_t const *)&rmask == 0x12) 89 #endif 90 d = cucul_create_dither(32, w, h, 4 * w, 91 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); 92 else 93 d = cucul_create_dither(32, w, h, 4 * w, 94 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff); 95 96 cucul_dither_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, 97 cucul_get_height(qq) - 1, d, buf); 98 caca_display(kk); 99 100 caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, -1); 76 101 77 102 /* Free everything */ 103 caca_detach(kk); 78 104 free(buf); 105 cucul_free_dither(d); 79 106 cucul_free_font(f); 80 107 cucul_free(qq);
Note: See TracChangeset
for help on using the changeset viewer.