Browse Source

* src/caca.c:

+ Do not try the X11 driver if DISPLAY is set to the empty string.
  * examples/cacaview.c:
    + Cosmetic fixes.
tags/v0.99.beta14
Sam Hocevar sam 21 years ago
parent
commit
a21c3c0c9e
2 changed files with 8 additions and 4 deletions
  1. +7
    -3
      examples/cacaview.c
  2. +1
    -1
      src/caca.c

+ 7
- 3
examples/cacaview.c View File

@@ -1,5 +1,5 @@
/* /*
* view image viewer for libcaca
* cacaview image viewer for libcaca
* Copyright (c) 2003 Sam Hocevar <sam@zoy.org> * Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved * All Rights Reserved
* *
@@ -60,7 +60,9 @@ char *pixels = NULL;
struct caca_bitmap *bitmap = NULL; struct caca_bitmap *bitmap = NULL;
int x, y; int x, y;
unsigned int w, h, depth, bpp, rmask, gmask, bmask, amask; unsigned int w, h, depth, bpp, rmask, gmask, bmask, amask;
#if !defined(HAVE_IMLIB2_H)
unsigned int red[256], green[256], blue[256], alpha[256]; unsigned int red[256], green[256], blue[256], alpha[256];
#endif


int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@@ -287,8 +289,10 @@ int main(int argc, char **argv)
if(yn + y > (int)h) y = h - yn; if(yn + y > (int)h) y = h - yn;
newbitmap = caca_create_bitmap(bpp, 2 * xn, 2 * yn, depth * w, newbitmap = caca_create_bitmap(bpp, 2 * xn, 2 * yn, depth * w,
rmask, gmask, bmask, amask); rmask, gmask, bmask, amask);
#if !defined(HAVE_IMLIB2_H)
if(bpp == 8) if(bpp == 8)
caca_set_bitmap_palette(newbitmap, red, green, blue, alpha); caca_set_bitmap_palette(newbitmap, red, green, blue, alpha);
#endif
draw_checkers(0, fullscreen ? 0 : 1, draw_checkers(0, fullscreen ? 0 : 1,
ww - 1, fullscreen ? wh - 1 : wh - 3); ww - 1, fullscreen ? wh - 1 : wh - 3);
caca_draw_bitmap(0, fullscreen ? 0 : 1, caca_draw_bitmap(0, fullscreen ? 0 : 1,
@@ -368,7 +372,7 @@ int main(int argc, char **argv)


static void unload_image(void) static void unload_image(void)
{ {
#ifdef HAVE_IMLIB2_H
#if defined(HAVE_IMLIB2_H)
if(image) if(image)
imlib_free_image(); imlib_free_image();
image = NULL; image = NULL;
@@ -385,7 +389,7 @@ static void unload_image(void)


static void load_image(const char *name) static void load_image(const char *name)
{ {
#ifdef HAVE_IMLIB2_H
#if defined(HAVE_IMLIB2_H)
/* Load the new image */ /* Load the new image */
image = imlib_load_image(name); image = imlib_load_image(name);




+ 1
- 1
src/caca.c View File

@@ -407,7 +407,7 @@ static void caca_init_driver(void)
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
#if defined(HAVE_GETENV) #if defined(HAVE_GETENV)
if(getenv("DISPLAY"))
if(getenv("DISPLAY") && *(getenv("DISPLAY")))
#endif #endif
{ {
_caca_driver = CACA_DRIVER_X11; _caca_driver = CACA_DRIVER_X11;


Loading…
Cancel
Save