[w3m-dev 03279] w3m-img for framebuffer update

http://homepage3.nifty.com/slokar/fb/w3mfb.patch.gz
* w3mimg/fb/readme.txt: update
* w3mimg/fb/fb.c: update
* w3mimg/fb/fb.h: update
* w3mimg/fb/fb_gdkpixbuf.c: update
* w3mimg/fb/fb_img.c: update
* w3mimg/fb/fb_img.h: update
* w3mimg/fb/fb_imlib2.c: update
* w3mimg/fb/fb_w3mimg.c: update
* w3mimg/fb/fb_gdkpixbuf.h: deleted
* w3mimg/fb/fb_imlib2.h: deleted
* w3mimg/w3mimg.h (w3mimg_op): add get_image_size()
* w3mimg/x11/x11_w3mimg.c: update
* w3mimgdisplay.c (main): use get_image_size()
* w3mimgsize.c (main): use get_image_size()
From: Hiroyuki Ito <hito@crl.go.jp>
This commit is contained in:
Fumitoshi UKAI
2002-07-22 16:17:32 +00:00
parent b58f88a1e8
commit 9f103b13bb
15 changed files with 416 additions and 348 deletions

View File

@@ -1,6 +1,6 @@
/* $Id: fb.c,v 1.3 2002/07/18 15:10:52 ukai Exp $ */
/* $Id: fb.c,v 1.4 2002/07/22 16:17:32 ukai Exp $ */
/**************************************************************************
fb.c 0.2 Copyright (C) 2002, hito
fb.c 0.3 Copyright (C) 2002, hito
**************************************************************************/
#include <stdio.h>
@@ -21,6 +21,8 @@
#define FALSE 0
#define TRUE 1
#define IMAGE_SIZE_MAX 10000
static struct fb_cmap *fb_cmap_create(struct fb_fix_screeninfo *,
struct fb_var_screeninfo *);
static void fb_cmap_destroy(struct fb_cmap *cmap);
@@ -34,6 +36,7 @@ static struct fb_var_screeninfo vscinfo;
static struct fb_cmap *cmap = NULL;
static int is_open = FALSE;
static int fbfp = -1;
static size_t pixel_size = 0;
static unsigned char *buf = NULL;
int
@@ -75,51 +78,6 @@ fb_open(void)
goto ERR_END;
}
#if 0
if (fscinfo.visual == FB_VISUAL_PSEUDOCOLOR) {
printf("FB_VISUAL_PSEUDOCOLOR\n");
if (vscinfo.bits_per_pixel != 8) {
fprintf(stderr, "̤<>б<EFBFBD><D0B1>ե졼<D5A5><ECA1BC><EFBFBD>Хåե<C3A5>\n");
goto ERR_END;
}
if (fb_cmap_get(fbfp, cmap)) {
fprintf(stderr, "<22><><EFBFBD><EFBFBD>ޥå׳<C3A5><D7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
// fb_cmap_destroy(cmap);
goto ERR_END;
}
// fb_cmap_disp(cmap);
if (cmap->len < (LINUX_LOGO_COLORS + LOGO_COLOR_OFFSET)) {
fprintf(stderr, "<22><><EFBFBD>γ<EFBFBD><CEB3><EFBFBD><EFBFBD>ΰ褬<CEB0><E8A4AC>­<EFBFBD><C2AD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD>\n");
goto ERR_END;
}
cmap->start = LOGO_COLOR_OFFSET;
cmap->len = LINUX_LOGO_COLORS;
for (lp = 0; lp < LINUX_LOGO_COLORS; lp++) {
if (cmap->red) {
*(cmap->red + lp) =
(linux_logo_red[lp] << CHAR_BIT) + linux_logo_red[lp];
}
if (cmap->green) {
*(cmap->green + lp) =
(linux_logo_green[lp] << CHAR_BIT) + linux_logo_green[lp];
}
if (cmap->blue) {
*(cmap->blue + lp) =
(linux_logo_blue[lp] << CHAR_BIT) + linux_logo_blue[lp];
}
}
if (fb_cmap_set(fbfp, cmap)) {
fb_cmap_destroy(cmap);
fprintf(stderr, "<22><><EFBFBD><EFBFBD>ޥå׳<C3A5><D7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
goto ERR_END;
}
}
#endif
if (!(fscinfo.visual == FB_VISUAL_TRUECOLOR &&
(vscinfo.bits_per_pixel == 15 ||
vscinfo.bits_per_pixel == 16 ||
@@ -128,6 +86,8 @@ fb_open(void)
goto ERR_END;
}
pixel_size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
is_open = TRUE;
return 0;
@@ -158,20 +118,150 @@ fb_close(void)
is_open = FALSE;
}
FB_IMAGE *
fb_image_new(int width, int height)
{
FB_IMAGE *image;
if (is_open != TRUE)
return NULL;
if (width > IMAGE_SIZE_MAX || height > IMAGE_SIZE_MAX)
return NULL;
image = malloc(sizeof(*image));
if (image == NULL)
return NULL;
image->data = malloc(width * height * pixel_size);
if (image->data == NULL) {
free(image);
return NULL;
}
image->width = width;
image->height = height;
image->rowstride = width * pixel_size;
image->len = width * height * pixel_size;
return image;
}
void
fb_image_free(FB_IMAGE * image)
{
if (image == NULL)
return;
if (image->data != NULL)
free(image->data);
free(image);
}
void
fb_image_pset(FB_IMAGE * image, int x, int y, int r, int g, int b)
{
unsigned long work;
int offset;
if (image == NULL || is_open != TRUE || x >= image->width
|| y >= image->height)
return;
offset = image->rowstride * y + pixel_size * x;
work = ((r >> (CHAR_BIT - vscinfo.red.length)) << vscinfo.red.
offset) +
((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.
offset) +
((b >> (CHAR_BIT - vscinfo.blue.length)) << vscinfo.blue.offset);
memcpy(image->data + offset, &work, pixel_size);
}
int
fb_image_draw(FB_IMAGE * image, int x, int y, int sx, int sy, int width,
int height)
{
int i, offset_fb, offset_img;
if (image == NULL || is_open != TRUE ||
sx > image->width || sy > image->height ||
x > fb_width() || y > fb_height())
return 1;
if (x + width > fb_width())
width = fb_width() - x;
if (y + height > fb_height())
height = fb_height() - y;
offset_fb = fscinfo.line_length * y + pixel_size * x;
offset_img = image->rowstride * sy + pixel_size * sx;
for (i = 0; i < height; i++) {
memcpy(buf + offset_fb, image->data + offset_img, pixel_size * width);
offset_fb += fscinfo.line_length;
offset_img += image->rowstride;
}
return 0;
}
void
fb_image_rotete(FB_IMAGE * image, int direction)
{
unsigned char *src, *dest, *tmp;
int x, y, i, ofst;
if (image == NULL)
return;
tmp = malloc(image->len);
if (tmp == NULL)
return;
src = image->data;
dest = tmp;
if (direction) {
int ofst2 = image->rowstride * (image->height - 1);
for (x = 0; x < image->rowstride; x += pixel_size) {
ofst = ofst2 + x;
for (y = image->height - 1; y >= 0; y--) {
memcpy(dest, src + ofst, pixel_size);
dest += pixel_size;
ofst -= image->rowstride;
}
}
} else {
for (x = image->rowstride - pixel_size; x >= 0; x -= pixel_size) {
ofst = x;
for (y = 0; y < image->height; y++) {
memcpy(dest, src + ofst, pixel_size);
dest += pixel_size;
ofst += image->rowstride;
}
}
}
memcpy(src, tmp, image->len);
i = image->width;
image->width = image->height;
image->height = i;
image->rowstride = image->width * pixel_size;
free(tmp);
}
void
fb_pset(int x, int y, int r, int g, int b)
{
unsigned long work;
int offset;
static size_t size = 0;
if (is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
return;
if (size == 0)
size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
offset = fscinfo.line_length * y + size * x;
offset = fscinfo.line_length * y + pixel_size * x;
if (offset >= fscinfo.smem_len)
return;
@@ -180,7 +270,7 @@ fb_pset(int x, int y, int r, int g, int b)
((r >> (CHAR_BIT - vscinfo.red.length)) << vscinfo.red.offset) +
((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.offset) +
((b >> (CHAR_BIT - vscinfo.blue.length)) << vscinfo.blue.offset);
memcpy(buf + offset, &work, size);
memcpy(buf + offset, &work, pixel_size);
}
int
@@ -188,19 +278,16 @@ fb_get_color(int x, int y, int *r, int *g, int *b)
{
unsigned long work = 0;
int offset;
static size_t size = 0;
if (is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
return 1;
if (size == 0)
size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
offset = fscinfo.line_length * y + pixel_size * x;
offset = fscinfo.line_length * y + size * x;
if (offset >= fscinfo.smem_len)
return 1;
memcpy(&work, buf + offset, size);
memcpy(&work, buf + offset, pixel_size);
*r = ((work >> vscinfo.red.
offset) & (0x000000ff >> (CHAR_BIT - vscinfo.red.length)))

View File

@@ -1,17 +1,31 @@
/* $Id: fb.h,v 1.3 2002/07/18 15:01:31 ukai Exp $ */
/* $Id: fb.h,v 1.4 2002/07/22 16:17:32 ukai Exp $ */
#ifndef fb_header
#define fb_header
#include <linux/fb.h>
int fb_open(void);
typedef struct{
unsigned char *data;
int width;
int height;
int rowstride;
int len;
} FB_IMAGE;
FB_IMAGE *fb_image_new(int width, int height);
void fb_image_pset(FB_IMAGE *image, int x, int y, int r, int g, int b);
int fb_image_draw(FB_IMAGE *image, int x, int y, int sx, int sy, int width, int height);
void fb_image_free(FB_IMAGE *image);
void fb_image_rotete(FB_IMAGE *image, int direction);
int fb_open(void);
void fb_close(void);
void fb_pset(int x, int y, int r, int g, int b);
int fb_get_color(int x, int y, int *r, int *g, int *b);
void fb_clear(void);
int fb_width(void);
int fb_height(void);
void fb_cmap_disp(void);
void fb_fscrn_disp(void);
void fb_vscrn_disp(void);
int fb_get_color(int x, int y, int *r, int *g, int *b);
#endif

View File

@@ -1,137 +1,123 @@
/* $Id: fb_gdkpixbuf.c,v 1.5 2002/07/18 15:12:06 ukai Exp $ */
/* $Id: fb_gdkpixbuf.c,v 1.6 2002/07/22 16:17:32 ukai Exp $ */
/**************************************************************************
fb_gdkpixbuf.c 0.2 Copyright (C) 2002, hito
fb_gdkpixbuf.c 0.3 Copyright (C) 2002, hito
**************************************************************************/
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "fb.h"
#include "fb_img.h"
static void set_prm(IMAGE * img);
static void draw(FB_IMAGE * img, GdkPixbuf * pixbuf);
static GdkPixbuf *resize_image(GdkPixbuf * pixbuf, int width, int height);
IMAGE *
fb_load_image(char *filename, int w, int h)
int
get_image_size(char *filename, int *w, int *h)
{
GdkPixbuf *pixbuf;
IMAGE *img;
if (filename == NULL)
return 1;
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf == NULL)
return 1;
*w = gdk_pixbuf_get_width(pixbuf);
*h = gdk_pixbuf_get_height(pixbuf);
gdk_pixbuf_finalize(pixbuf);
return 0;
}
FB_IMAGE *
fb_image_load(char *filename, int w, int h)
{
GdkPixbuf *pixbuf;
FB_IMAGE *img;
if (filename == NULL)
return NULL;
img = malloc(sizeof(*img));
if (img == NULL)
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf == NULL)
return NULL;
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf == NULL) {
free(img);
pixbuf = resize_image(pixbuf, w, h);
if (pixbuf == NULL)
return NULL;
w = gdk_pixbuf_get_width(pixbuf);
h = gdk_pixbuf_get_height(pixbuf);
img = fb_image_new(w, h);
if (img == NULL) {
gdk_pixbuf_finalize(pixbuf);
return NULL;
}
img->pixbuf = pixbuf;
set_prm(img);
draw(img, pixbuf);
fb_resize_image(img, w, h);
gdk_pixbuf_finalize(pixbuf);
return img;
}
int
fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width, int height)
void
draw(FB_IMAGE * img, GdkPixbuf * pixbuf)
{
int i, j, r, g, b, offset, bpp;
int i, j, r, g, b, offset, bpp, rowstride;
guchar *pixels;
gboolean alpha;
if (img == NULL)
return 1;
if (img == NULL || pixbuf == NULL)
return;
bpp = img->rowstride / img->width;
for (j = sy; j < sy + height && j < img->height; j++) {
offset = j * img->rowstride + bpp * sx;
for (i = sx; i < sx + width && i < img->width; i++, offset += bpp) {
r = img->pixels[offset];
g = img->pixels[offset + 1];
b = img->pixels[offset + 2];
if (img->alpha && img->pixels[offset + 3] == 0)
fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b);
rowstride = gdk_pixbuf_get_rowstride(pixbuf);
pixels = gdk_pixbuf_get_pixels(pixbuf);
alpha = gdk_pixbuf_get_has_alpha(pixbuf);
bpp = rowstride / img->width;
for (j = 0; j < img->height; j++) {
offset = j * rowstride;
for (i = 0; i < img->width; i++, offset += bpp) {
r = pixels[offset];
g = pixels[offset + 1];
b = pixels[offset + 2];
if (alpha && pixels[offset + 3] == 0)
fb_image_pset(img, i, j, bg_r, bg_g, bg_b);
else
fb_pset(i + x - sx, j + y - sy, r, g, b);
fb_image_pset(img, i, j, r, g, b);
}
}
return 0;
return;
}
int
fb_resize_image(IMAGE * img, int width, int height)
static GdkPixbuf *
resize_image(GdkPixbuf * pixbuf, int width, int height)
{
GdkPixbuf *pixbuf;
if (width < 1 || height < 1 || img == NULL)
return 1;
GdkPixbuf * resized_pixbuf;
int w, h;
if (width == img->width && height == img->height)
return 0;
pixbuf =
gdk_pixbuf_scale_simple(img->pixbuf, width, height, GDK_INTERP_HYPER);
if (pixbuf == NULL)
return 1;
gdk_pixbuf_finalize(img->pixbuf);
img->pixbuf = pixbuf;
set_prm(img);
return 0;
}
void
fb_free_image(IMAGE * img)
{
if (img == NULL)
return;
gdk_pixbuf_finalize(img->pixbuf);
free(img);
}
IMAGE *
fb_dup_image(IMAGE * img)
{
GdkPixbuf *pixbuf;
IMAGE *new_img;
if (img == NULL)
return NULL;
new_img = malloc(sizeof(*img));
if (new_img == NULL)
w = gdk_pixbuf_get_width(pixbuf);
h = gdk_pixbuf_get_height(pixbuf);
if (width < 1 || height < 1)
return pixbuf;
if (w == width && h == height)
return pixbuf;
resized_pixbuf =
gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_HYPER);
gdk_pixbuf_finalize(pixbuf);
if (resized_pixbuf == NULL)
return NULL;
pixbuf = gdk_pixbuf_copy(img->pixbuf);
if (pixbuf == NULL) {
free(new_img);
return NULL;
}
new_img->pixbuf = pixbuf;
set_prm(new_img);
return new_img;
}
int
fb_rotate_image(IMAGE * img, int angle)
{
return 1;
}
static void
set_prm(IMAGE * img)
{
GdkPixbuf *pixbuf;
if (img == NULL)
return;
pixbuf = img->pixbuf;
img->pixels = gdk_pixbuf_get_pixels(pixbuf);
img->width = gdk_pixbuf_get_width(pixbuf);
img->height = gdk_pixbuf_get_height(pixbuf);
img->alpha = gdk_pixbuf_get_has_alpha(pixbuf);
img->rowstride = gdk_pixbuf_get_rowstride(pixbuf);
return resized_pixbuf;
}

View File

@@ -1,16 +0,0 @@
/* $Id: fb_gdkpixbuf.h,v 1.3 2002/07/18 15:01:31 ukai Exp $ */
#ifndef fb_gdkpixbuf_header
#define fb_gdkpixbuf_header
#include <gdk-pixbuf/gdk-pixbuf.h>
typedef struct {
int width;
int height;
int rowstride;
int alpha;
GdkPixbuf *pixbuf;
guchar *pixels;
} IMAGE;
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: fb_img.c,v 1.3 2002/07/18 15:13:13 ukai Exp $ */
/* $Id: fb_img.c,v 1.4 2002/07/22 16:17:32 ukai Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -18,13 +18,13 @@ static int bg_r = 0, bg_g = 0, bg_b = 0;
#endif
int
fb_draw_image_simple(IMAGE * img, int x, int y)
fb_image_draw_simple(FB_IMAGE * img, int x, int y)
{
return fb_draw_image(img, x, y, 0, 0, img->width, img->height);
return fb_image_draw(img, x, y, 0, 0, img->width, img->height);
}
void
fb_set_bg(int r, int g, int b)
fb_image_set_bg(int r, int g, int b)
{
bg_r = r;
bg_g = g;

View File

@@ -1,24 +1,11 @@
/* $Id: fb_img.h,v 1.3 2002/07/18 15:01:31 ukai Exp $ */
/* $Id: fb_img.h,v 1.4 2002/07/22 16:17:32 ukai Exp $ */
#ifndef fb_img_header
#define fb_img_header
#include "config.h"
#include "fb.h"
#if defined(USE_IMLIB2)
#include "w3mimg/fb/fb_imlib2.h"
#elif defined(USE_GDKPIXBUF)
#include "w3mimg/fb/fb_gdkpixbuf.h"
#else
#error no Imlib2 and GdkPixbuf support
#endif
IMAGE *fb_load_image(char *filename, int w, int h);
int fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width,
int height);
int fb_draw_image_simple(IMAGE * img, int x, int y);
int fb_resize_image(IMAGE * img, int width, int height);
void fb_free_image(IMAGE * img);
void fb_set_bg(int r, int g, int b);
IMAGE *fb_dup_image(IMAGE * img);
int fb_rotate_image(IMAGE * img, int angle);
FB_IMAGE *fb_image_load(char *filename, int w, int h);
int fb_image_draw_simple(FB_IMAGE * img, int x, int y);
void fb_image_set_bg(int r, int g, int b);
int get_image_size(char *filename, int *w, int *h);
#endif

View File

@@ -1,162 +1,124 @@
/* $Id: fb_imlib2.c,v 1.5 2002/07/18 15:14:21 ukai Exp $ */
/* $Id: fb_imlib2.c,v 1.6 2002/07/22 16:17:32 ukai Exp $ */
/**************************************************************************
fb_imlib2.c 0.2 Copyright (C) 2002, hito
fb_imlib2.c 0.3 Copyright (C) 2002, hito
**************************************************************************/
#include <X11/Xlib.h>
#include <Imlib2.h>
#include "fb.h"
#include "fb_img.h"
static void set_prm(IMAGE * img);
static void draw(FB_IMAGE * img, Imlib_Image image);
static Imlib_Image resize_image(Imlib_Image image, int width, int height);
IMAGE *
fb_load_image(char *filename, int w, int h)
int
get_image_size(char *filename, int *w, int *h)
{
Imlib_Image image;
IMAGE *img;
if (filename == NULL)
return 1;
image = imlib_load_image(filename);
if (image == NULL)
return 1;
imlib_context_set_image(image);
*w = imlib_image_get_width();
*h = imlib_image_get_height();
imlib_free_image();
return 0;
}
FB_IMAGE *
fb_image_load(char *filename, int w, int h)
{
Imlib_Image image;
FB_IMAGE *img;
if (filename == NULL)
return NULL;
img = malloc(sizeof(*img));
if (img == NULL)
image = imlib_load_image(filename);
if (image == NULL)
return NULL;
image = imlib_load_image(filename);
if (image == NULL) {
free(img);
image = resize_image(image, w, h);
if (image == NULL)
return NULL;
}
imlib_context_set_image(image);
img->image = image;
set_prm(img);
w = imlib_image_get_width();
h = imlib_image_get_height();
fb_resize_image(img, w, h);
img = fb_image_new(w, h);
if (img == NULL) {
imlib_free_image();
return NULL;
}
draw(img, image);
imlib_free_image();
return img;
}
int
fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width, int height)
static void
draw(FB_IMAGE * img, Imlib_Image image)
{
int i, j, r, g, b, a = 0, offset;
DATA32 *data;
if (img == NULL)
return 1;
return;
for (j = sy; j < sy + height && j < img->height; j++) {
offset = j * img->width;
for (i = sx; i < sx + width && i < img->width; i++) {
a = (img->data[offset + i] >> 24) & 0x000000ff;
r = (img->data[offset + i] >> 16) & 0x000000ff;
g = (img->data[offset + i] >> 8) & 0x000000ff;
b = (img->data[offset + i]) & 0x000000ff;
imlib_context_set_image(image);
data = imlib_image_get_data_for_reading_only();
for (j = 0; j < img->height; j++) {
offset = img->width * j;
for (i = 0; i < img->width; i++) {
a = (data[offset + i] >> 24) & 0x000000ff;
r = (data[offset + i] >> 16) & 0x000000ff;
g = (data[offset + i] >> 8) & 0x000000ff;
b = (data[offset + i]) & 0x000000ff;
if (a == 0)
fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b);
fb_image_pset(img, i, j, bg_r, bg_g, bg_b);
else
fb_pset(i + x - sx, j + y - sy, r, g, b);
fb_image_pset(img, i, j, r, g, b);
}
}
return 0;
return;
}
int
fb_resize_image(IMAGE * img, int width, int height)
static Imlib_Image
resize_image(Imlib_Image image, int width, int height)
{
Imlib_Image image;
Imlib_Image resized_image;
int w, h;
if (width < 1 || height < 1 || img == NULL)
return 1;
if (width == img->width && height == img->height)
return 0;
image =
imlib_create_cropped_scaled_image(0, 0, img->width, img->height, width,
height);
if (image == NULL)
return 1;
return NULL;
imlib_context_set_image(image);
w = imlib_image_get_width();
h = imlib_image_get_height();
if (width < 1 || height < 1)
return image;
if (w == width && h == height)
return image;
resized_image =
imlib_create_cropped_scaled_image(0, 0, w, h, width, height);
imlib_context_set_image(img->image);
imlib_free_image();
img->image = image;
set_prm(img);
return 0;
}
void
fb_free_image(IMAGE * img)
{
if (img == NULL)
return;
imlib_context_set_image(img->image);
imlib_free_image();
free(img);
}
IMAGE *
fb_dup_image(IMAGE * img)
{
Imlib_Image image;
IMAGE *new_img;
if (img == NULL)
return NULL;
new_img = malloc(sizeof(*img));
if (new_img == NULL)
return NULL;
imlib_context_set_image(img->image);
image = imlib_clone_image();
if (image == NULL) {
free(new_img);
return NULL;
}
new_img->image = image;
set_prm(new_img);
return new_img;
}
int
fb_rotate_image(IMAGE * img, int angle)
{
int orientation;
if (img == NULL)
return 1;
imlib_context_set_image(img->image);
if (angle == 90) {
orientation = 1;
}
else if (angle == -90) {
orientation = 3;
}
else {
return 1;
}
imlib_image_orientate(orientation);
set_prm(img);
return 0;
}
static void
set_prm(IMAGE * img)
{
if (img == NULL)
return;
imlib_context_set_image(img->image);
img->data = imlib_image_get_data_for_reading_only();
img->width = imlib_image_get_width();
img->height = imlib_image_get_height();
return resized_image;
}

View File

@@ -1,15 +0,0 @@
/* $Id: fb_imlib2.h,v 1.3 2002/07/18 15:01:31 ukai Exp $ */
#ifndef fb_imlib2_header
#define fb_imlib2_header
#include <X11/Xlib.h>
#include <Imlib2.h>
typedef struct {
int width;
int height;
Imlib_Image image;
DATA32 *data;
} IMAGE;
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: fb_w3mimg.c,v 1.1 2002/07/17 20:58:48 ukai Exp $ */
/* $Id: fb_w3mimg.c,v 1.2 2002/07/22 16:17:32 ukai Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -39,7 +39,7 @@ w3mfb_set_background(w3mimg_op *self, char *background)
if (background) {
int r, g, b;
if (sscanf(background, "#%02x%02x%02x", &r, &g, &b) == 3)
fb_set_bg(r, g, b);
fb_image_set_bg(r, g, b);
}
}
@@ -58,11 +58,11 @@ w3mfb_close(w3mimg_op *self)
static int
w3mfb_load_image(w3mimg_op *self, W3MImage *img, char *fname, int w, int h)
{
IMAGE *im;
FB_IMAGE *im;
if (self == NULL)
return 0;
im = fb_load_image(fname, w, h);
im = fb_image_load(fname, w, h);
if (!im)
return 0;
img->pixmap = im;
@@ -79,7 +79,7 @@ w3mfb_show_image(w3mimg_op *self, W3MImage *img, int sx, int sy,
if (self == NULL)
return 0;
fb_draw_image((IMAGE *)img->pixmap,
fb_image_draw((FB_IMAGE *)img->pixmap,
x + self->offset_x, y + self->offset_y,
sx, sy,
(sw ? sw : img->width),
@@ -93,13 +93,27 @@ w3mfb_free_image(w3mimg_op *self, W3MImage *img)
if (self == NULL)
return;
if (img && img->pixmap) {
fb_free_image((IMAGE *)img->pixmap);
fb_image_free((FB_IMAGE *)img->pixmap);
img->pixmap = NULL;
img->width = 0;
img->height = 0;
}
}
static int
w3mfb_get_image_size(w3mimg_op *self, W3MImage *img,
char *fname, int *w, int *h)
{
int i;
if (self == NULL)
return 0;
i = get_image_size(fname, w, h);
if (i)
return 0;
return 1;
}
w3mimg_op *
w3mimg_fbopen()
{
@@ -125,6 +139,7 @@ w3mimg_fbopen()
wop->load_image = w3mfb_load_image;
wop->show_image = w3mfb_show_image;
wop->free_image = w3mfb_free_image;
wop->get_image_size = w3mfb_get_image_size;
return wop;
error:

View File

@@ -63,6 +63,10 @@ original readme.txt
<20><>2002/07/07 ImageMagick <20><>ư<EFBFBD><C6B0><EFBFBD><EFBFBD>ǧ
<20><>2002/07/10 GdkPixbuf <20><>ư<EFBFBD><C6B0><EFBFBD><EFBFBD>ǧ
<20><>2002/07/11 Imlib2 <20><>ư<EFBFBD><C6B0><EFBFBD><EFBFBD>ǧ
<20><>2002/07/15 Version 0.1
<20><><EFBFBD><EFBFBD>
<20><>2002/07/22 Version 0.2
<20><><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD>®<EFBFBD><C2AE>
<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ZXB01226@nifty.com

View File

@@ -1,4 +1,4 @@
/* $Id: w3mimg.h,v 1.3 2002/07/18 15:14:51 ukai Exp $ */
/* $Id: w3mimg.h,v 1.4 2002/07/22 16:17:32 ukai Exp $ */
#include "config.h"
#ifdef USE_W3MIMG_FB
@@ -29,6 +29,8 @@ typedef struct _w3mimg_op {
int (*show_image) (struct _w3mimg_op * self, W3MImage * img,
int sx, int sy, int sw, int sh, int x, int y);
void (*free_image) (struct _w3mimg_op * self, W3MImage * img);
int (*get_image_size) (struct _w3mimg_op * self, W3MImage * img,
char *fname, int *w, int *h);
} w3mimg_op;
#ifdef USE_W3MIMG_X11

View File

@@ -1,4 +1,4 @@
/* $Id: x11_w3mimg.c,v 1.4 2002/07/18 15:15:32 ukai Exp $ */
/* $Id: x11_w3mimg.c,v 1.5 2002/07/22 16:17:32 ukai Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -194,6 +194,27 @@ x11_free_image(w3mimg_op * self, W3MImage * img)
}
}
static int
x11_get_image_size(w3mimg_op * self, W3MImage * img, char *fname, int *w, int *h)
{
struct x11_info *xi;
ImlibImage *im;
if (self == NULL)
return 0;
xi = (struct x11_info *)self->priv;
if (xi == NULL)
return 0;
im = Imlib_load_image(xi->id, fname);
if (!im)
return 0;
*w = im->rgb_width;
*h = im->rgb_height;
Imlib_kill_image(xi->id, im);
return 1;
}
/* *INDENT-OFF* */
/*
@@ -319,6 +340,7 @@ w3mimg_x11open()
wop->load_image = x11_load_image;
wop->show_image = x11_show_image;
wop->free_image = x11_free_image;
wop->get_image_size = x11_get_image_size;
return wop;
error: