* w3mimg/w3mimg.h: created * w3mimg/x11/x11_w3mimg.c: created * w3mimg/fb/fb_w3mimg.c: created * w3mimgsize.c w3mimgdisplay.c: modified * configure: modified * XMakefile: modified * config.h.dist: updated From: Fumitoshi UKAI <ukai@debian.or.jp> w3m-img for framebuffer support * http://homepage3.nifty.com/slokar/fb/ * w3mimg/fb/fb.c w3mimg/fb/fb.h w3mimg/fb/fb_img.c w3mimg/fb/fb_img.h w3mimg/fb/fb_gdkpixbuf.c w3mimg/fb/fb_gdkpixbuf.h w3mimg/fb/fb_imlib2.c w3mimg/fb/fb_imlib.h w3mimg/fb/readme.txt w3mimg/fb/license.txt: added From: Hiroshi Kawashima <kei@sm.sony.co.jp>
		
			
				
	
	
		
			134 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			134 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* $Id: fb_w3mimg.c,v 1.1 2002/07/17 20:58:48 ukai Exp $ */
 | 
						|
#include <stdio.h>
 | 
						|
#include <stdlib.h>
 | 
						|
#include <ctype.h>
 | 
						|
 | 
						|
#include "w3mimg/fb/fb.h"
 | 
						|
#include "w3mimg/fb/fb_img.h"
 | 
						|
#include "w3mimg/w3mimg.h"
 | 
						|
 | 
						|
static int
 | 
						|
w3mfb_init(w3mimg_op *self)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return 0;
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
static int
 | 
						|
w3mfb_finish(w3mimg_op *self)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return 0;
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
static int
 | 
						|
w3mfb_active(w3mimg_op *self)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return 0;
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
static void
 | 
						|
w3mfb_set_background(w3mimg_op *self, char *background)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return;
 | 
						|
    if (background) {
 | 
						|
	int r, g, b;
 | 
						|
	if (sscanf(background, "#%02x%02x%02x", &r, &g, &b) == 3)
 | 
						|
	    fb_set_bg(r, g, b);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
static void
 | 
						|
w3mfb_sync(w3mimg_op *self)
 | 
						|
{
 | 
						|
    return;
 | 
						|
}
 | 
						|
 | 
						|
static void
 | 
						|
w3mfb_close(w3mimg_op *self)
 | 
						|
{
 | 
						|
    fb_close();
 | 
						|
}
 | 
						|
 | 
						|
static int
 | 
						|
w3mfb_load_image(w3mimg_op *self, W3MImage *img, char *fname, int w, int h)
 | 
						|
{
 | 
						|
    IMAGE *im;
 | 
						|
 | 
						|
    if (self == NULL)
 | 
						|
	return 0;
 | 
						|
    im = fb_load_image(fname, w, h);
 | 
						|
    if (!im)
 | 
						|
	return 0;
 | 
						|
    img->pixmap = im;
 | 
						|
    img->width = im->width;
 | 
						|
    img->height = im->height;
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
static int
 | 
						|
w3mfb_show_image(w3mimg_op *self, W3MImage *img, int sx, int sy, 
 | 
						|
		 int sw, int sh,
 | 
						|
		 int x, int y)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return 0;
 | 
						|
 | 
						|
    fb_draw_image((IMAGE *)img->pixmap,
 | 
						|
		  x + self->offset_x, y + self->offset_y,
 | 
						|
		  sx, sy,
 | 
						|
		  (sw ? sw : img->width),
 | 
						|
		  (sh ? sh : img->height));
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
static void
 | 
						|
w3mfb_free_image(w3mimg_op *self, W3MImage *img)
 | 
						|
{
 | 
						|
    if (self == NULL)
 | 
						|
	return;
 | 
						|
    if (img && img->pixmap) {
 | 
						|
	fb_free_image((IMAGE *)img->pixmap);
 | 
						|
	img->pixmap = NULL;
 | 
						|
	img->width = 0;
 | 
						|
	img->height = 0;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
w3mimg_op *
 | 
						|
w3mimg_fbopen()
 | 
						|
{
 | 
						|
    w3mimg_op *wop = NULL;
 | 
						|
    wop = (w3mimg_op *)malloc(sizeof(w3mimg_op));
 | 
						|
    if (wop == NULL)
 | 
						|
	return NULL;
 | 
						|
    memset(wop, 0, sizeof(w3mimg_op));
 | 
						|
 | 
						|
    if (fb_open())
 | 
						|
	goto error;
 | 
						|
 | 
						|
    wop->width = fb_width();
 | 
						|
    wop->height = fb_height();
 | 
						|
    
 | 
						|
    wop->init = w3mfb_init;
 | 
						|
    wop->finish = w3mfb_finish;
 | 
						|
    wop->active = w3mfb_active;
 | 
						|
    wop->set_background = w3mfb_set_background;
 | 
						|
    wop->sync = w3mfb_sync;
 | 
						|
    wop->close = w3mfb_close;
 | 
						|
 | 
						|
    wop->load_image = w3mfb_load_image;
 | 
						|
    wop->show_image = w3mfb_show_image;
 | 
						|
    wop->free_image = w3mfb_free_image;
 | 
						|
 | 
						|
    return wop;
 | 
						|
error:
 | 
						|
    free(wop);
 | 
						|
    return NULL;
 | 
						|
}
 |