1 /* $Id: fb_w3mimg.c,v 1.14 2004/08/04 17:32:28 ukai Exp $ */
11 #include "w3mimg/fb/fb.h"
12 #include "w3mimg/fb/fb_img.h"
13 #include "w3mimg/w3mimg.h"
16 w3mfb_init(w3mimg_op * self)
25 w3mfb_finish(w3mimg_op * self)
33 w3mfb_active(w3mimg_op * self)
41 w3mfb_set_background(w3mimg_op * self, char *background)
47 if (sscanf(background, "#%02x%02x%02x", &r, &g, &b) == 3)
48 fb_image_set_bg(r, g, b);
53 w3mfb_sync(w3mimg_op * self)
59 w3mfb_close(w3mimg_op * self)
65 w3mfb_clear(w3mimg_op * self, int x, int y, int w, int h)
69 fb_image_clear(x, y, w, h);
74 w3mfb_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
80 im = fb_image_load(fname, w, h, self->max_anim);
84 img->width = im[0]->width;
85 img->height = im[0]->height;
90 w3mfb_show_image(w3mimg_op * self, W3MImage * img, int sx, int sy,
91 int sw, int sh, int x, int y)
100 if (img->pixmap == NULL)
103 frame = (FB_IMAGE **) img->pixmap;
105 fb_image_draw(frame[i],
106 x + self->offset_x, y + self->offset_y,
107 sx, sy, (sw ? sw : img->width), (sh ? sh : img->height));
108 if (frame[0]->num > 1) {
109 if (frame[1]->id > WAIT_CNT) {
111 if (i < frame[0]->num - 1)
112 frame[0]->id = i + 1;
122 w3mfb_free_image(w3mimg_op * self, W3MImage * img)
126 if (img && img->pixmap) {
127 fb_frame_free((FB_IMAGE **) img->pixmap);
135 w3mfb_get_image_size(w3mimg_op * self, W3MImage * img,
136 char *fname, int *w, int *h)
142 i = get_image_size(fname, w, h);
148 #ifdef W3MIMGDISPLAY_SETUID
150 check_tty_console(char *tty)
152 if (tty == NULL || *tty == '\0')
154 if (strncmp(tty, "/dev/", 5) == 0)
156 if (strncmp(tty, "tty", 3) == 0 && isdigit(*(tty + 3)))
158 if (strncmp(tty, "vc/", 3) == 0 && isdigit(*(tty + 3)))
163 #define check_tty_console(tty) 1
169 w3mimg_op *wop = NULL;
170 wop = (w3mimg_op *) malloc(sizeof(w3mimg_op));
173 memset(wop, 0, sizeof(w3mimg_op));
175 if (!check_tty_console(getenv("W3M_TTY")) && strcmp("jfbterm", getenv("TERM")) != 0) {
176 fprintf(stderr, "w3mimgdisplay/fb: tty is not console\n");
183 wop->width = fb_width();
184 wop->height = fb_height();
186 wop->init = w3mfb_init;
187 wop->finish = w3mfb_finish;
188 wop->active = w3mfb_active;
189 wop->set_background = w3mfb_set_background;
190 wop->sync = w3mfb_sync;
191 wop->close = w3mfb_close;
192 wop->clear = w3mfb_clear;
194 wop->load_image = w3mfb_load_image;
195 wop->show_image = w3mfb_show_image;
196 wop->free_image = w3mfb_free_image;
197 wop->get_image_size = w3mfb_get_image_size;