[w3m-dev 03935] Re: clear image
* w3mimg/fb/fb.c (fb_get_packed_color): added (fb_image_pset): use fb_get_packed_color (fb_image_fill): use fb_get_packed_color (fb_clear): use tmp to store pixels From: Hiroyuki Ito <hito@crl.go.jp>
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,11 @@
|
|||||||
|
2003-07-09 Hiroyuki Ito <hito@crl.go.jp>
|
||||||
|
|
||||||
|
* [w3m-dev 03935] Re: clear image
|
||||||
|
* w3mimg/fb/fb.c (fb_get_packed_color): added
|
||||||
|
(fb_image_pset): use fb_get_packed_color
|
||||||
|
(fb_image_fill): use fb_get_packed_color
|
||||||
|
(fb_clear): use tmp to store pixels
|
||||||
|
|
||||||
2003-07-09 ABE Yuji <cbo46560@pop12.odn.ne.jp>
|
2003-07-09 ABE Yuji <cbo46560@pop12.odn.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03934] Re: clear image
|
* [w3m-dev 03934] Re: clear image
|
||||||
@@ -7903,4 +7911,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.847 2003/07/08 17:32:12 ukai Exp $
|
$Id: ChangeLog,v 1.848 2003/07/09 15:02:28 ukai Exp $
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: fb.c,v 1.13 2003/07/08 17:30:37 ukai Exp $ */
|
/* $Id: fb.c,v 1.14 2003/07/09 15:02:28 ukai Exp $ */
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
fb.c 0.3 Copyright (C) 2002, hito
|
fb.c 0.3 Copyright (C) 2002, hito
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -49,6 +49,7 @@ static int fb_cmap_set(int fbfp, struct fb_cmap *cmap);
|
|||||||
static int fb_cmap_get(int fbfp, struct fb_cmap *cmap);
|
static int fb_cmap_get(int fbfp, struct fb_cmap *cmap);
|
||||||
static int fb_cmap_init(void);
|
static int fb_cmap_init(void);
|
||||||
static int fb_get_cmap_index(int r, int g, int b);
|
static int fb_get_cmap_index(int r, int g, int b);
|
||||||
|
static unsigned long fb_get_packed_color(int r, int g, int b);
|
||||||
|
|
||||||
static struct fb_fix_screeninfo fscinfo;
|
static struct fb_fix_screeninfo fscinfo;
|
||||||
static struct fb_var_screeninfo vscinfo;
|
static struct fb_var_screeninfo vscinfo;
|
||||||
@@ -214,16 +215,7 @@ fb_image_pset(FB_IMAGE * image, int x, int y, int r, int g, int b)
|
|||||||
|| y >= image->height)
|
|| y >= image->height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pixel_size == 1) {
|
work = fb_get_packed_color(r, g, b);
|
||||||
work = fb_get_cmap_index(r, g, b);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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 + image->rowstride * y + pixel_size * x, &work,
|
memcpy(image->data + image->rowstride * y + pixel_size * x, &work,
|
||||||
pixel_size);
|
pixel_size);
|
||||||
}
|
}
|
||||||
@@ -237,16 +229,7 @@ fb_image_fill(FB_IMAGE * image, int r, int g, int b)
|
|||||||
if (image == NULL || is_open != TRUE)
|
if (image == NULL || is_open != TRUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pixel_size == 1) {
|
work = fb_get_packed_color(r, g, b);
|
||||||
work = fb_get_cmap_index(r, g, b);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (offset = 0; offset < image->len; offset += pixel_size) {
|
for (offset = 0; offset < image->len; offset += pixel_size) {
|
||||||
memcpy(image->data + offset, &work, pixel_size);
|
memcpy(image->data + offset, &work, pixel_size);
|
||||||
@@ -368,8 +351,9 @@ fb_height(void)
|
|||||||
int
|
int
|
||||||
fb_clear(int x, int y, int w, int h, int r, int g, int b)
|
fb_clear(int x, int y, int w, int h, int r, int g, int b)
|
||||||
{
|
{
|
||||||
unsigned long work;
|
|
||||||
int i, j, offset_fb;
|
int i, j, offset_fb;
|
||||||
|
static int rr = -1, gg = -1, bb = -1;
|
||||||
|
static char *tmp = NULL;
|
||||||
|
|
||||||
if (is_open != TRUE || x > fb_width() || y > fb_height())
|
if (is_open != TRUE || x > fb_width() || y > fb_height())
|
||||||
return 1;
|
return 1;
|
||||||
@@ -378,21 +362,47 @@ fb_clear(int x, int y, int w, int h, int r, int g, int b)
|
|||||||
if (y + h > fb_height())
|
if (y + h > fb_height())
|
||||||
h = fb_height() - y;
|
h = fb_height() - y;
|
||||||
|
|
||||||
|
if (tmp == NULL) {
|
||||||
|
tmp = malloc(fscinfo.line_length);
|
||||||
|
if (tmp == NULL)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (rr != r || gg != g || bb != b) {
|
||||||
|
unsigned long work;
|
||||||
|
int ww = fb_width();
|
||||||
|
|
||||||
|
work = fb_get_packed_color(r, g, b);
|
||||||
|
for (i = 0; i < ww; i++)
|
||||||
|
memcpy(tmp + pixel_size * i, &work, pixel_size);
|
||||||
|
rr = r;
|
||||||
|
gg = g;
|
||||||
|
bb = b;
|
||||||
|
}
|
||||||
offset_fb = fscinfo.line_length * y + pixel_size * x;
|
offset_fb = fscinfo.line_length * 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);
|
|
||||||
for (i = 0; i < h; i++) {
|
for (i = 0; i < h; i++) {
|
||||||
for (j = 0; j < w; j++)
|
memcpy(buf + offset_fb, tmp, pixel_size * w);
|
||||||
memcpy(buf + offset_fb + pixel_size * j, &work, pixel_size);
|
|
||||||
offset_fb += fscinfo.line_length;
|
offset_fb += fscinfo.line_length;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********* static functions **************/
|
/********* static functions **************/
|
||||||
static
|
static unsigned long
|
||||||
int
|
fb_get_packed_color(int r, int g, int b)
|
||||||
|
{
|
||||||
|
if (pixel_size == 1) {
|
||||||
|
return fb_get_cmap_index(r, g, b);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return
|
||||||
|
((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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
fb_get_cmap_index(int r, int g, int b)
|
fb_get_cmap_index(int r, int g, int b)
|
||||||
{
|
{
|
||||||
int work;
|
int work;
|
||||||
|
|||||||
Reference in New Issue
Block a user