mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-09 10:05:49 +01:00
many bug fixes, finished some delegate code, updated menu file bug from EXEC
to SHEXEC, updated french translations
This commit is contained in:
103
wrlib/scale.c
103
wrlib/scale.c
@@ -47,6 +47,107 @@
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef broken_code
|
||||
RImage*
|
||||
RScaleImage(RImage *image, unsigned new_width, unsigned new_height)
|
||||
{
|
||||
int ox;
|
||||
int px, py;
|
||||
register int x, y, t;
|
||||
int dx, dy;
|
||||
unsigned char *sr, *sg, *sb, *sa;
|
||||
unsigned char *dr, *dg, *db, *da;
|
||||
RImage *img;
|
||||
|
||||
assert(new_width >= 0 && new_height >= 0);
|
||||
|
||||
if (new_width == image->width && new_height == image->height)
|
||||
return RCloneImage(image);
|
||||
|
||||
img = RCreateImage(new_width, new_height, image->data[3]!=NULL);
|
||||
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
/* fixed point math idea taken from Imlib by
|
||||
* Carsten Haitzler (Rasterman) */
|
||||
dx = (image->width<<16)/new_width;
|
||||
dy = (image->height<<16)/new_height;
|
||||
|
||||
py = 0;
|
||||
|
||||
dr = img->data[0];
|
||||
dg = img->data[1];
|
||||
db = img->data[2];
|
||||
da = img->data[3];
|
||||
|
||||
if (image->data[3]!=NULL) {
|
||||
int ot;
|
||||
ot = -1;
|
||||
for (y=0; y<new_height; y++) {
|
||||
t = image->width*(py>>16);
|
||||
|
||||
sr = image->data[0]+t;
|
||||
sg = image->data[1]+t;
|
||||
sb = image->data[2]+t;
|
||||
sa = image->data[3]+t;
|
||||
|
||||
ot = t;
|
||||
ox = 0;
|
||||
px = 0;
|
||||
for (x=0; x<new_width; x++) {
|
||||
px += dx;
|
||||
|
||||
*(dr++) = *sr;
|
||||
*(dg++) = *sg;
|
||||
*(db++) = *sb;
|
||||
*(da++) = *sa;
|
||||
|
||||
t = (px - ox)>>16;
|
||||
ox += t<<16;
|
||||
|
||||
sr += t;
|
||||
sg += t;
|
||||
sb += t;
|
||||
sa += t;
|
||||
}
|
||||
py += dy;
|
||||
}
|
||||
} else {
|
||||
int ot;
|
||||
ot = -1;
|
||||
for (y=0; y<new_height; y++) {
|
||||
t = image->width*(py>>16);
|
||||
|
||||
sr = image->data[0]+t;
|
||||
sg = image->data[1]+t;
|
||||
sb = image->data[2]+t;
|
||||
|
||||
ot = t;
|
||||
ox = 0;
|
||||
px = 0;
|
||||
for (x=0; x<new_width; x++) {
|
||||
px += dx;
|
||||
|
||||
*(dr++) = *sr;
|
||||
*(dg++) = *sg;
|
||||
*(db++) = *sb;
|
||||
|
||||
t = (px-ox)>>16;
|
||||
ox += t<<16;
|
||||
|
||||
sr += t;
|
||||
sg += t;
|
||||
sb += t;
|
||||
}
|
||||
py += dy;
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
#else
|
||||
RImage*
|
||||
RScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||
{
|
||||
@@ -144,7 +245,7 @@ RScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
30
wrlib/xpm.c
30
wrlib/xpm.c
@@ -97,12 +97,18 @@ RGetImageFromXPMData(RContext *context, char **data)
|
||||
|
||||
for (i=0; i<xpm.ncolors; i++) {
|
||||
XColor xcolor;
|
||||
|
||||
|
||||
if (strncmp(xpm.colorTable[i].c_color,"None",4)==0) {
|
||||
color_table[0][i]=0;
|
||||
color_table[1][i]=0;
|
||||
color_table[2][i]=0;
|
||||
transp = i;
|
||||
if (context->dpy) {
|
||||
/* ??? */
|
||||
color_table[0][i]=context->red_offset;
|
||||
color_table[1][i]=context->red_offset;
|
||||
color_table[2][i]=context->red_offset;
|
||||
} else {
|
||||
color_table[0][i]=0;
|
||||
color_table[1][i]=0;
|
||||
color_table[2][i]=0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (XParseColor(dpy, cmap, xpm.colorTable[i].c_color, &xcolor)) {
|
||||
@@ -207,9 +213,17 @@ RLoadXPM(RContext *context, char *file, int index)
|
||||
XColor xcolor;
|
||||
|
||||
if (strncmp(xpm.colorTable[i].c_color,"None",4)==0) {
|
||||
color_table[0][i]=0;
|
||||
color_table[1][i]=0;
|
||||
color_table[2][i]=0;
|
||||
if (context->dpy) {
|
||||
/* ??? */
|
||||
color_table[0][i]=context->red_offset;
|
||||
color_table[1][i]=context->red_offset;
|
||||
color_table[2][i]=context->red_offset;
|
||||
} else {
|
||||
color_table[0][i]=0;
|
||||
color_table[1][i]=0;
|
||||
color_table[2][i]=0;
|
||||
}
|
||||
|
||||
transp = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user