예제 #1
0
static int
analogtv_load_xpm(analogtv *it, analogtv_input *input, char **xpm)
{
  Pixmap pixmap;
  XImage *image;
  int width,height;
  int rc;

  pixmap=xpm_data_to_pixmap (it->dpy, it->window, xpm,
                             &width, &height, NULL);
  image = XGetImage(it->dpy, pixmap, 0, 0, width, height, ~0L, ZPixmap);
  XFreePixmap(it->dpy, pixmap);
  rc=analogtv_load_ximage(it, input, image);
  if (image) XDestroyImage(image);
  return rc;
}
static void
init_images (struct state *st)
{
  Pixmap *images[8];
#if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
  char **bits[8];
#else
  unsigned char *bits[8];
#endif

  int i = 0;
  images[i++] = &st->left1;
  images[i++] = &st->left2;
  images[i++] = &st->right1;
  images[i++] = &st->right2;
  images[i++] = &st->left_front;
  images[i++] = &st->right_front;
  images[i++] = &st->front;
  images[i]   = &st->down;

#if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)

  i = 0;
  bits[i++] = nose_l1_xpm;
  bits[i++] = nose_l2_xpm;
  bits[i++] = nose_r1_xpm;
  bits[i++] = nose_r2_xpm;
  bits[i++] = nose_f2_xpm;
  bits[i++] = nose_f3_xpm;
  bits[i++] = nose_f1_xpm;
  bits[i]   = nose_f4_xpm;

  for (i = 0; i < sizeof (images) / sizeof(*images); i++)
    {
      Pixmap pixmap = xpm_data_to_pixmap (st->dpy, st->window, bits[i],
                                          0, 0, 0);
      if (!pixmap)
	{
	  fprintf (stderr, "%s: Can't load nose images\n", progname);
	  exit (1);
	}
      *images[i] = pixmap;
    }
#else
  i = 0;
  bits[i++] = nose_l1_bits;
  bits[i++] = nose_l2_bits;
  bits[i++] = nose_r1_bits;
  bits[i++] = nose_r2_bits;
  bits[i++] = nose_f2_bits;
  bits[i++] = nose_f3_bits;
  bits[i++] = nose_f1_bits;
  bits[i++] = nose_f4_bits;

  for (i = 0; i < sizeof (images) / sizeof(*images); i++)
    if (!(*images[i] =
	  XCreatePixmapFromBitmapData(st->dpy, st->window,
				      (char *) bits[i], 64, 64, 1, 0, 1)))
      {
	fprintf (stderr, "%s: Can't load nose images\n", progname);
	exit (1);
      }
#endif
}