diff --git a/configure.ac b/configure.ac index 6964279..906fc7c 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,10 @@ case "${target_os}" in esac AM_CONDITIONAL(NEED_PIC, ${NEED_PIC}) +# Build cacaview? +AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no) +AM_CONDITIONAL(IMLIB2_CONFIG, test "${IMLIB2_CONFIG}" != "no") + # Build documentation? AC_PATH_PROG(DOXYGEN, doxygen, no) AM_CONDITIONAL(DOXYGEN, test "${DOXYGEN}" != "no") diff --git a/examples/Makefile.am b/examples/Makefile.am index 5411d55..84d4454 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -13,7 +13,7 @@ if USE_NCURSES LDFLAGS_ncurses = -lncurses endif -bin_PROGRAMS = cacademo caca-spritedit cacaview +bin_PROGRAMS = cacademo caca-spritedit $(cacaview) cacademo_SOURCES = demo.c cacademo_LDADD = ../src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm @@ -23,8 +23,12 @@ caca_spritedit_SOURCES = spritedit.c caca_spritedit_LDADD = ../src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm caca_spritedit_CPPFLAGS = -I$(top_srcdir)/src +if IMLIB2_CONFIG +cacaview = cacaview cacaview_SOURCES = view.c -cacaview_LDADD = ../src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm +cacaview_LDADD = ../src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) cacaview_CPPFLAGS = -I$(top_srcdir)/src cacaview_CFLAGS = `imlib2-config --cflags` cacaview_LDFLAGS = `imlib2-config --libs` +endif + diff --git a/examples/demo.c b/examples/demo.c index b19fb7d..6c468f3 100644 --- a/examples/demo.c +++ b/examples/demo.c @@ -27,11 +27,6 @@ #include #include -#if 0 -#include -#include -#endif - #include "caca.h" static void display_menu(void); @@ -45,30 +40,19 @@ static void demo_boxes(void); static void demo_ellipses(void); static void demo_triangles(void); static void demo_sprites(void); -#if 0 -static void demo_blit(void); -#endif int bounds = 0; int outline = 0; int dithering = 0; struct caca_sprite *sprite = NULL; -#if 0 -GdkPixbuf *pixbuf; -char *pixels; -int bufx, bufy, bufpitch; -#endif - int main(int argc, char **argv) { void (*demo)(void) = NULL; int quit = 0; if(caca_init()) - { return 1; - } caca_set_delay(40000); @@ -78,31 +62,8 @@ int main(int argc, char **argv) sprite = caca_load_sprite("caca.txt"); if(!sprite) sprite = caca_load_sprite("examples/caca.txt"); - -#if 0 -gdk_init (&argc, &argv); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/gally4.jpeg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/badge1.jpeg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/union.png", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/pikachu.jpeg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/gradient.png", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/beastie.png", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/stitch.jpg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/caca.jpg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/dranac.jpeg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/artwork/aboire.png", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/web/sam.zoy.org/artwork/goret.png", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/lilkim02.jpg", NULL); - //pixbuf = gdk_pixbuf_new_from_file("/home/sam/etw.bmp", NULL); - pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/lena_std.png", NULL); -if(!pixbuf) return -2; - pixels = gdk_pixbuf_get_pixels(pixbuf); - bufx = gdk_pixbuf_get_width(pixbuf); - bufy = gdk_pixbuf_get_height(pixbuf); - bufpitch = gdk_pixbuf_get_rowstride(pixbuf); -fprintf(stderr, "bits: %i\n", gdk_pixbuf_get_bits_per_sample(pixbuf)); -fprintf(stderr, "w %i, h %i, stride %i\n", bufx, bufy, bufpitch); -#endif + if(!sprite) + return 1; /* Main menu */ display_menu(); @@ -173,12 +134,6 @@ fprintf(stderr, "w %i, h %i, stride %i\n", bufx, bufy, bufpitch); case 'S': demo = demo_sprites; break; -#if 0 - case 'i': - case 'I': - demo = demo_blit; - break; -#endif } if(demo) @@ -242,9 +197,6 @@ static void display_menu(void) caca_putstr(4, 12, "'5': ellipses"); caca_putstr(4, 13, "'s': sprites"); caca_putstr(4, 14, "'c': color"); -#if 0 - caca_putstr(4, 15, "'i': image blit"); -#endif caca_putstr(4, 17, "settings:"); caca_printf(4, 18, "'o': outline: %s", @@ -502,11 +454,3 @@ static void demo_sprites(void) caca_rand(0, caca_get_height() - 1), sprite, 0); } -#if 0 -static void demo_blit(void) -{ - caca_blit(6, 4, caca_get_width() - 6, caca_get_height() - 4, - pixels, bufx, bufy); -} -#endif - diff --git a/examples/view.c b/examples/view.c index 86ede73..6260e15 100644 --- a/examples/view.c +++ b/examples/view.c @@ -34,7 +34,7 @@ Imlib_Image image = NULL; char *pixels = NULL; struct caca_bitmap *bitmap = NULL; -int dithering = 0; +int dithering = 1; const enum caca_dithering dithering_list[] = { CACA_DITHER_NONE, CACA_DITHER_ORDERED, CACA_DITHER_RANDOM }; @@ -109,19 +109,19 @@ int main(int argc, char **argv) update = 1; break; case CACA_EVENT_KEY_PRESS | CACA_KEY_UP: - if(zoom > 0) y -= h / (2 + zoom) / 8; + if(zoom > 0) y -= 1 + h / (2 + zoom) / 8; update = 1; break; case CACA_EVENT_KEY_PRESS | CACA_KEY_DOWN: - if(zoom > 0) y += h / (2 + zoom) / 8; + if(zoom > 0) y += 1 + h / (2 + zoom) / 8; update = 1; break; case CACA_EVENT_KEY_PRESS | CACA_KEY_LEFT: - if(zoom > 0) x -= w / (2 + zoom) / 8; + if(zoom > 0) x -= 1 + w / (2 + zoom) / 8; update = 1; break; case CACA_EVENT_KEY_PRESS | CACA_KEY_RIGHT: - if(zoom > 0) x += w / (2 + zoom) / 8; + if(zoom > 0) x += 1 + w / (2 + zoom) / 8; update = 1; break; case CACA_EVENT_KEY_PRESS | 'q':