mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-02 22:25:48 +01:00
bug fixes, performance enhancement for image rendering
This commit is contained in:
@@ -42,7 +42,7 @@ static Bool bestContext(Display *dpy, int screen_number, RContext *context);
|
||||
|
||||
static RContextAttributes DEFAULT_CONTEXT_ATTRIBS = {
|
||||
RC_UseSharedMemory|RC_RenderMode|RC_ColorsPerChannel, /* flags */
|
||||
RM_DITHER, /* render_mode */
|
||||
RDitheredRendering, /* render_mode */
|
||||
4, /* colors_per_channel */
|
||||
0,
|
||||
0,
|
||||
@@ -204,7 +204,7 @@ allocateGrayScale(RContext *ctx)
|
||||
|
||||
if (ncolors>=256 && ctx->vclass==StaticGray) {
|
||||
/* don't need dithering for 256 levels of gray in StaticGray visual */
|
||||
ctx->attribs->render_mode = RM_MATCH;
|
||||
ctx->attribs->render_mode = RBestMatchRendering;
|
||||
}
|
||||
|
||||
colors = malloc(sizeof(XColor)*ncolors);
|
||||
@@ -491,7 +491,7 @@ RCreateContext(Display *dpy, int screen_number, RContextAttributes *attribs)
|
||||
context->blue_offset = count_offset(context->visual->blue_mask);
|
||||
/* disable dithering on 24 bits visuals */
|
||||
if (context->depth >= 24)
|
||||
context->attribs->render_mode = RM_MATCH;
|
||||
context->attribs->render_mode = RBestMatchRendering;
|
||||
}
|
||||
|
||||
/* check avaiability of MIT-SHM */
|
||||
|
||||
197
wrlib/convert.c
197
wrlib/convert.c
@@ -93,6 +93,147 @@ computeTable(unsigned short mask)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static RXImage*
|
||||
image2TrueColorD16(RContext *ctx, RImage *image)
|
||||
{
|
||||
RXImage *ximg;
|
||||
register int x, y, r, g, b;
|
||||
unsigned char *red, *grn, *blu;
|
||||
unsigned short rmask, gmask, bmask;
|
||||
unsigned short roffs, goffs, boffs;
|
||||
unsigned short *rtable, *gtable, *btable;
|
||||
int ofs;
|
||||
|
||||
ximg = RCreateXImage(ctx, ctx->depth, image->width, image->height);
|
||||
if (!ximg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
red = image->data[0];
|
||||
grn = image->data[1];
|
||||
blu = image->data[2];
|
||||
|
||||
roffs = ctx->red_offset;
|
||||
goffs = ctx->green_offset;
|
||||
boffs = ctx->blue_offset;
|
||||
|
||||
rmask = ctx->visual->red_mask >> roffs;
|
||||
gmask = ctx->visual->green_mask >> goffs;
|
||||
bmask = ctx->visual->blue_mask >> boffs;
|
||||
|
||||
rtable = computeTable(rmask);
|
||||
gtable = computeTable(gmask);
|
||||
btable = computeTable(bmask);
|
||||
|
||||
if (rtable==NULL || gtable==NULL || btable==NULL) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
/* dither */
|
||||
short *rerr, *gerr, *berr;
|
||||
short *nrerr, *ngerr, *nberr;
|
||||
short *terr;
|
||||
unsigned short *dataP;
|
||||
int line_offset;
|
||||
int rer, ger, ber;
|
||||
const int dr=0xff/rmask;
|
||||
const int dg=0xff/gmask;
|
||||
const int db=0xff/bmask;
|
||||
|
||||
rerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
gerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
berr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
nrerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
ngerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
nberr = (short*)alloca((image->width+2)*sizeof(short));
|
||||
if (!rerr || !gerr || !berr || !nrerr || !ngerr || !nberr) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
RDestroyXImage(ctx, ximg);
|
||||
return NULL;
|
||||
}
|
||||
for (x=0; x<image->width; x++) {
|
||||
rerr[x] = red[x];
|
||||
gerr[x] = grn[x];
|
||||
berr[x] = blu[x];
|
||||
}
|
||||
rerr[x] = gerr[x] = berr[x] = 0;
|
||||
|
||||
dataP = (unsigned short*)ximg->image->data;
|
||||
line_offset = ximg->image->bytes_per_line - image->width * 2;
|
||||
|
||||
/* convert and dither the image to XImage */
|
||||
for (y=0, ofs=0; y<image->height; y++) {
|
||||
if (y<image->height-1) {
|
||||
int x1;
|
||||
for (x=0, x1=ofs+image->width; x<image->width; x++, x1++) {
|
||||
nrerr[x] = red[x1];
|
||||
ngerr[x] = grn[x1];
|
||||
nberr[x] = blu[x1];
|
||||
}
|
||||
/* last column */
|
||||
x1--;
|
||||
nrerr[x] = red[x1];
|
||||
ngerr[x] = grn[x1];
|
||||
nberr[x] = blu[x1];
|
||||
}
|
||||
for (x=0; x<image->width; x++) {
|
||||
/* reduce pixel */
|
||||
if (rerr[x]>0xff) rerr[x]=0xff; else if (rerr[x]<0) rerr[x]=0;
|
||||
if (gerr[x]>0xff) gerr[x]=0xff; else if (gerr[x]<0) gerr[x]=0;
|
||||
if (berr[x]>0xff) berr[x]=0xff; else if (berr[x]<0) berr[x]=0;
|
||||
|
||||
r = rtable[rerr[x]];
|
||||
g = gtable[gerr[x]];
|
||||
b = btable[berr[x]];
|
||||
|
||||
*(dataP++) = (r<<roffs) | (g<<goffs) | (b<<boffs);
|
||||
|
||||
/* calc error */
|
||||
rer = rerr[x] - r*dr;
|
||||
ger = gerr[x] - g*dg;
|
||||
ber = berr[x] - b*db;
|
||||
|
||||
/* distribute error */
|
||||
r = (rer*3)/8;
|
||||
g = (ger*3)/8;
|
||||
b = (ber*3)/8;
|
||||
/* x+1, y */
|
||||
rerr[x+1]+=r;
|
||||
gerr[x+1]+=g;
|
||||
berr[x+1]+=b;
|
||||
/* x, y+1 */
|
||||
nrerr[x]+=r;
|
||||
ngerr[x]+=g;
|
||||
nberr[x]+=b;
|
||||
/* x+1, y+1 */
|
||||
nrerr[x+1]+=rer-2*r;
|
||||
ngerr[x+1]+=ger-2*g;
|
||||
nberr[x+1]+=ber-2*b;
|
||||
}
|
||||
ofs += image->width;
|
||||
(char*)dataP += line_offset;
|
||||
/* skip to next line */
|
||||
terr = rerr;
|
||||
rerr = nrerr;
|
||||
nrerr = terr;
|
||||
|
||||
terr = gerr;
|
||||
gerr = ngerr;
|
||||
ngerr = terr;
|
||||
|
||||
terr = berr;
|
||||
berr = nberr;
|
||||
nberr = terr;
|
||||
}
|
||||
}
|
||||
return ximg;
|
||||
}
|
||||
|
||||
|
||||
static RXImage*
|
||||
image2TrueColor(RContext *ctx, RImage *image)
|
||||
{
|
||||
@@ -151,7 +292,7 @@ image2TrueColor(RContext *ctx, RImage *image)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ctx->attribs->render_mode==RM_MATCH) {
|
||||
if (ctx->attribs->render_mode==RBestMatchRendering) {
|
||||
/* fake match */
|
||||
#ifdef DEBUG
|
||||
puts("true color match");
|
||||
@@ -264,6 +405,8 @@ image2TrueColor(RContext *ctx, RImage *image)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static RXImage*
|
||||
image2PseudoColor(RContext *ctx, RImage *image)
|
||||
{
|
||||
@@ -303,7 +446,7 @@ image2PseudoColor(RContext *ctx, RImage *image)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ctx->attribs->render_mode == RM_MATCH) {
|
||||
if (ctx->attribs->render_mode == RBestMatchRendering) {
|
||||
/* fake match */
|
||||
#ifdef DEBUG
|
||||
printf("pseudo color match with %d colors per channel\n", cpc);
|
||||
@@ -477,7 +620,7 @@ image2GrayScale(RContext *ctx, RImage *image)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ctx->attribs->render_mode == RM_MATCH) {
|
||||
if (ctx->attribs->render_mode == RBestMatchRendering) {
|
||||
/* fake match */
|
||||
#ifdef DEBUG
|
||||
printf("grayscale match with %d colors per channel\n", cpc);
|
||||
@@ -594,12 +737,18 @@ RConvertImage(RContext *context, RImage *image, Pixmap *pixmap)
|
||||
assert(pixmap!=NULL);
|
||||
|
||||
/* clear error message */
|
||||
if (context->vclass == TrueColor)
|
||||
ximg = image2TrueColor(context, image);
|
||||
else if (context->vclass == PseudoColor || context->vclass == StaticColor)
|
||||
ximg = image2PseudoColor(context, image);
|
||||
if (context->vclass == TrueColor) {
|
||||
|
||||
if (context->attribs->render_mode == RDitheredRendering
|
||||
&& (context->depth == 15 || context->depth == 16))
|
||||
ximg = image2TrueColorD16(context, image);
|
||||
else
|
||||
ximg = image2TrueColor(context, image);
|
||||
|
||||
} else if (context->vclass == PseudoColor || context->vclass == StaticColor)
|
||||
ximg = image2PseudoColor(context, image);
|
||||
else if (context->vclass == GrayScale || context->vclass == StaticGray)
|
||||
ximg = image2GrayScale(context, image);
|
||||
ximg = image2GrayScale(context, image);
|
||||
|
||||
if (!ximg) {
|
||||
#ifdef C_ALLOCA
|
||||
@@ -696,37 +845,6 @@ RConvertImageMask(RContext *context, RImage *image, Pixmap *pixmap,
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
RSmoothScaleBorderConvertImage(RContext *context, RImage *image,
|
||||
int newWidth, int newHeight, int borderType,
|
||||
Pixmap *pixmap)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
RScaleBorderConvertImage(RContext *context, RImage *image,
|
||||
int newWidth, int newHeight, int borderType,
|
||||
Pixmap *pixmap)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Bool
|
||||
RGetClosestXColor(RContext *context, RColor *color, XColor *retColor)
|
||||
{
|
||||
@@ -801,3 +919,4 @@ RGetClosestXColor(RContext *context, RColor *color, XColor *retColor)
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
185
wrlib/scale.c
185
wrlib/scale.c
@@ -48,102 +48,101 @@
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
RImage*
|
||||
RScaleImage(RImage *image, unsigned new_width, unsigned new_height)
|
||||
RScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||
{
|
||||
int ox;
|
||||
int px, py;
|
||||
register int x, y, t;
|
||||
int dx, dy;
|
||||
int ddy, ee;
|
||||
int h2;
|
||||
int yd;
|
||||
int xd, xs;
|
||||
RImage *dst;
|
||||
int e, xd2;
|
||||
unsigned char *sr, *sg, *sb, *sa;
|
||||
unsigned char *dr, *dg, *db, *da;
|
||||
RImage *img;
|
||||
int ys = 0;
|
||||
|
||||
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;
|
||||
dst = RCreateImage(new_width, new_height, src->data[3]!=NULL);
|
||||
|
||||
py = 0;
|
||||
|
||||
dr = img->data[0];
|
||||
dg = img->data[1];
|
||||
db = img->data[2];
|
||||
da = img->data[3];
|
||||
ddy = src->height/2;
|
||||
ee = (ddy/2) - dst->height;
|
||||
h2 = new_height/2;
|
||||
|
||||
if (image->data[3]!=NULL) {
|
||||
int ot;
|
||||
ot = -1;
|
||||
for (y=0; y<new_height; y++) {
|
||||
t = image->width*(py>>16);
|
||||
xd = dst->width;
|
||||
xs = src->width/2;
|
||||
e = (src->width/2)-xd;
|
||||
xd2 = xd/2;
|
||||
|
||||
sr = image->data[0]+t;
|
||||
sg = image->data[1]+t;
|
||||
sb = image->data[2]+t;
|
||||
sa = image->data[3]+t;
|
||||
sr = src->data[0];
|
||||
sg = src->data[1];
|
||||
sb = src->data[2];
|
||||
sa = src->data[3];
|
||||
|
||||
ot = t;
|
||||
ox = 0;
|
||||
px = 0;
|
||||
for (x=0; x<new_width; x++) {
|
||||
px += dx;
|
||||
dr = dst->data[0];
|
||||
dg = dst->data[1];
|
||||
db = dst->data[2];
|
||||
da = dst->data[3];
|
||||
|
||||
if (sa == NULL) {
|
||||
for (yd = 0; yd < new_height; yd++) {
|
||||
int x;
|
||||
|
||||
sr = src->data[0] + ys * src->width;
|
||||
sg = src->data[1] + ys * src->width;
|
||||
sb = src->data[2] + ys * src->width;
|
||||
|
||||
for (x = 0; x < xd; x++) {
|
||||
*(dr++) = *sr;
|
||||
*(dg++) = *sg;
|
||||
*(db++) = *sb;
|
||||
|
||||
while (e >= 0) {
|
||||
sr++;
|
||||
sg++;
|
||||
sb++;
|
||||
e -= xd2;
|
||||
}
|
||||
e += xs;
|
||||
}
|
||||
while (ee >= 0) {
|
||||
ys++;
|
||||
ee -= h2;
|
||||
}
|
||||
ee += ddy;
|
||||
}
|
||||
} else {
|
||||
for (yd = 0; yd < new_height; yd++) {
|
||||
int x;
|
||||
|
||||
sr = src->data[0] + ys * src->width;
|
||||
sg = src->data[1] + ys * src->width;
|
||||
sb = src->data[2] + ys * src->width;
|
||||
sa = src->data[3] + ys * src->width;
|
||||
|
||||
for (x = 0; x < xd; x++) {
|
||||
*(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;
|
||||
while (e >= 0) {
|
||||
sr++;
|
||||
sg++;
|
||||
sb++;
|
||||
sa++;
|
||||
e -= xd2;
|
||||
}
|
||||
e += xs;
|
||||
}
|
||||
py += dy;
|
||||
while (ee >= 0) {
|
||||
ys++;
|
||||
ee -= h2;
|
||||
}
|
||||
ee += ddy;
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +158,7 @@ RScaleImage(RImage *image, unsigned new_width, unsigned new_height)
|
||||
/*
|
||||
* filter function definitions
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#define filter_support (1.0)
|
||||
|
||||
static double
|
||||
@@ -171,7 +170,7 @@ double t;
|
||||
if(t < 1.0) return((2.0 * t - 3.0) * t * t + 1.0);
|
||||
return(0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
#define box_support (0.5)
|
||||
|
||||
static double
|
||||
@@ -304,8 +303,8 @@ _wraster_change_filter(int type)
|
||||
break;
|
||||
default:
|
||||
case RMitchellFilter:
|
||||
filterf = Mitchell_support;
|
||||
fwidth = Mitchell_filter;
|
||||
filterf = Mitchell_filter;
|
||||
fwidth = Mitchell_support;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -332,7 +331,7 @@ CLIST *contrib; /* array of contribution lists */
|
||||
|
||||
|
||||
RImage*
|
||||
RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||
{
|
||||
RImage *tmp; /* intermediate image */
|
||||
double xscale, yscale; /* zoom scale factors */
|
||||
@@ -345,19 +344,19 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
unsigned char *rp, *gp, *bp;
|
||||
unsigned char *rsp, *gsp, *bsp;
|
||||
|
||||
dst = RCreateImage(newWidth, newHeight, False);
|
||||
dst = RCreateImage(new_width, new_height, False);
|
||||
|
||||
/* create intermediate image to hold horizontal zoom */
|
||||
tmp = RCreateImage(dst->width, src->height, False);
|
||||
xscale = (double)newWidth / (double)src->width;
|
||||
yscale = (double)newHeight / (double)src->height;
|
||||
xscale = (double)new_width / (double)src->width;
|
||||
yscale = (double)new_height / (double)src->height;
|
||||
|
||||
/* pre-calculate filter contributions for a row */
|
||||
contrib = (CLIST *)calloc(newWidth, sizeof(CLIST));
|
||||
contrib = (CLIST *)calloc(new_width, sizeof(CLIST));
|
||||
if (xscale < 1.0) {
|
||||
width = fwidth / xscale;
|
||||
fscale = 1.0 / xscale;
|
||||
for (i = 0; i < newWidth; ++i) {
|
||||
for (i = 0; i < new_width; ++i) {
|
||||
contrib[i].n = 0;
|
||||
contrib[i].p = (CONTRIB *)calloc((int)(width * 2 + 1),
|
||||
sizeof(CONTRIB));
|
||||
@@ -380,7 +379,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 0; i < newWidth; ++i) {
|
||||
for(i = 0; i < new_width; ++i) {
|
||||
contrib[i].n = 0;
|
||||
contrib[i].p = (CONTRIB *)calloc((int) (fwidth * 2 + 1),
|
||||
sizeof(CONTRIB));
|
||||
@@ -490,7 +489,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
gsp = malloc(tmp->height);
|
||||
bsp = malloc(tmp->height);
|
||||
|
||||
for(k = 0; k < newWidth; ++k) {
|
||||
for(k = 0; k < new_width; ++k) {
|
||||
rp = dst->data[0] + k;
|
||||
gp = dst->data[1] + k;
|
||||
bp = dst->data[2] + k;
|
||||
@@ -516,7 +515,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
*d++ = *p;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < newHeight; ++i) {
|
||||
for(i = 0; i < new_height; ++i) {
|
||||
rweight = gweight = bweight = 0.0;
|
||||
for(j = 0; j < contrib[i].n; ++j) {
|
||||
rweight += rsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;
|
||||
@@ -526,9 +525,9 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
||||
*rp = CLAMP(rweight, 0, 255);
|
||||
*gp = CLAMP(gweight, 0, 255);
|
||||
*bp = CLAMP(bweight, 0, 255);
|
||||
rp += newWidth;
|
||||
gp += newWidth;
|
||||
bp += newWidth;
|
||||
rp += new_width;
|
||||
gp += new_width;
|
||||
bp += new_width;
|
||||
}
|
||||
}
|
||||
free(rsp);
|
||||
|
||||
@@ -526,7 +526,7 @@ int main(int argc, char **argv)
|
||||
|
||||
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
||||
|
||||
attr.render_mode = RM_DITHER;
|
||||
attr.render_mode = RDitheredRendering;
|
||||
attr.colors_per_channel = 4;
|
||||
|
||||
if (visualID >= 0) {
|
||||
|
||||
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
RContextAttributes attr;
|
||||
RColor **colors = NULL;
|
||||
int i, rmode = RM_DITHER, ncolors = 0, cpc = 4;
|
||||
int i, rmode = RDitheredRendering, ncolors = 0, cpc = 4;
|
||||
char **color_name;
|
||||
XColor color;
|
||||
XSetWindowAttributes val;
|
||||
@@ -59,9 +59,9 @@ int main(int argc, char **argv)
|
||||
if (argc>1) {
|
||||
for (i=1; i<argc; i++) {
|
||||
if (strcmp(argv[i], "-m")==0) {
|
||||
rmode = RM_MATCH;
|
||||
rmode = RBestMatchRendering;
|
||||
} else if (strcmp(argv[i], "-d")==0) {
|
||||
rmode = RM_DITHER;
|
||||
rmode = RDitheredRendering;
|
||||
} else if (strcmp(argv[i], "-c")==0) {
|
||||
i++;
|
||||
if (i>=argc) {
|
||||
@@ -161,11 +161,11 @@ int main(int argc, char **argv)
|
||||
gettimeofday(&timev, NULL);
|
||||
t1 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
||||
if (i%3==0)
|
||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_HORIZONTAL);
|
||||
imgh = RRenderMultiGradient(550, 550, colors, RGRD_HORIZONTAL);
|
||||
else if (i%3==1)
|
||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_VERTICAL);
|
||||
imgh = RRenderMultiGradient(550, 550, colors, RGRD_VERTICAL);
|
||||
else
|
||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_DIAGONAL);
|
||||
imgh = RRenderMultiGradient(550, 550, colors, RGRD_DIAGONAL);
|
||||
|
||||
gettimeofday(&timev, NULL);
|
||||
t2 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
||||
|
||||
15
wrlib/view.c
15
wrlib/view.c
@@ -9,6 +9,8 @@ RContext *ctx;
|
||||
RImage *img;
|
||||
Pixmap pix;
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
RContextAttributes attr;
|
||||
@@ -19,7 +21,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
||||
attr.render_mode = RM_DITHER;
|
||||
attr.render_mode = RDitheredRendering;
|
||||
attr.colors_per_channel = 4;
|
||||
ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
|
||||
if (argc<2)
|
||||
@@ -31,18 +33,27 @@ int main(int argc, char **argv)
|
||||
puts(RMessageForError(RErrorCode));
|
||||
exit(1);
|
||||
}
|
||||
/*
|
||||
if (argc > 2) {
|
||||
RImage *tmp = img;
|
||||
|
||||
img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
|
||||
tmp->height*atol(argv[2]));
|
||||
RDestroyImage(tmp);
|
||||
}
|
||||
*/
|
||||
|
||||
if (argc > 2) {
|
||||
img = RScaleImage(img, img->width*atof(argv[2]),
|
||||
img->height*atof(argv[2]));
|
||||
}
|
||||
if (!RConvertImage(ctx, img, &pix)) {
|
||||
puts(RMessageForError(RErrorCode));
|
||||
exit(1);
|
||||
}
|
||||
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, img->width,
|
||||
|
||||
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
|
||||
img->width,
|
||||
img->height, 0, 0, 0);
|
||||
RDestroyImage(img);
|
||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||
|
||||
@@ -322,7 +322,8 @@ void RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
|
||||
|
||||
RImage *RScaleImage(RImage *image, unsigned new_width, unsigned new_height);
|
||||
|
||||
RImage *RSmoothScaleImage(RImage *src, int newWidth, int newHeight);
|
||||
RImage *RSmoothScaleImage(RImage *src, unsigned new_width,
|
||||
unsigned new_height);
|
||||
|
||||
RImage *RMakeTiledImage(RImage *tile, unsigned width, unsigned height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user