mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
Implement some more methods
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@13285 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
304a139434
commit
c8444cdff3
7 changed files with 18 additions and 1321 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-04-01 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/xlib/GSContext (-GSCurrentCTM): Implement
|
||||
(-GSSetCTM:): Likewise.
|
||||
(-GSConcatCTM:): Likewise.
|
||||
* Source/xlib/XGGState.m ([XGGState -DPSsetmiterlimit:]): Implement
|
||||
to do nothing.
|
||||
|
||||
* Source/x11/GNUmakefile: Remove unsed draw.c, gradient.c, misc.c
|
||||
|
||||
2002-03-31 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/x11/XGServerWindow.m
|
||||
|
|
|
@ -562,18 +562,17 @@ static unsigned int unique_index = 0;
|
|||
|
||||
- (NSAffineTransform *) GSCurrentCTM
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
return nil;
|
||||
return [gstate GSCurrentCTM];
|
||||
}
|
||||
|
||||
- (void) GSSetCTM: (NSAffineTransform *)ctm
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSSetCTM: ctm];
|
||||
}
|
||||
|
||||
- (void) GSConcatCTM: (NSAffineTransform *)ctm
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSConcatCTM: ctm];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -47,9 +47,6 @@ x11_C_FILES = \
|
|||
StdCmap.c \
|
||||
context.c \
|
||||
convert.c \
|
||||
draw.c \
|
||||
gradient.c \
|
||||
misc.c \
|
||||
raster.c \
|
||||
scale.c \
|
||||
xdnd.c \
|
||||
|
|
|
@ -1,605 +0,0 @@
|
|||
/* draw.c - pixel plotting, line drawing
|
||||
*
|
||||
* Raster graphics library
|
||||
*
|
||||
* Copyright (c) 1998 Dan Pascu
|
||||
* Copyright (c) 2000 Alfredo K. Kojima
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "x11/wraster.h"
|
||||
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Returns the color of the pixel at coordinates (x, y) in "color".
|
||||
*/
|
||||
Bool
|
||||
RGetPixel(RImage *image, int x, int y, RColor *color)
|
||||
{
|
||||
int ofs;
|
||||
|
||||
assert(image!=NULL);
|
||||
if (x < 0 || x >= image->width
|
||||
|| y < 0 || y >= image->height)
|
||||
return False;
|
||||
|
||||
if (image->format == RRGBAFormat) {
|
||||
ofs = (y*image->width + x) * 4;
|
||||
color->red = image->data[ofs];
|
||||
color->green = image->data[ofs++];
|
||||
color->blue = image->data[ofs++];
|
||||
color->alpha = image->data[ofs];
|
||||
} else {
|
||||
ofs = (y*image->width + x) * 3;
|
||||
color->red = image->data[ofs++];
|
||||
color->green = image->data[ofs++];
|
||||
color->blue = image->data[ofs++];
|
||||
/* If the image does not have alpha channel, we consider alpha 255 */
|
||||
color->alpha = 255;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RPutPixel(RImage *image, int x, int y, RColor *color)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
|
||||
assert(image!=NULL);
|
||||
assert(color!=NULL);
|
||||
if (x < 0 || x >= image->width || y < 0 || y >= image->height)
|
||||
return;
|
||||
|
||||
if (image->format == RRGBAFormat) {
|
||||
ptr = image->data + (y*image->width + x) * 4;
|
||||
} else {
|
||||
ptr = image->data + (y*image->width + x) * 3;
|
||||
}
|
||||
|
||||
if (color->alpha==255) {
|
||||
*ptr++ = color->red;
|
||||
*ptr++ = color->green;
|
||||
*ptr++ = color->blue;
|
||||
if (image->format == RRGBAFormat) {
|
||||
*ptr = 255;
|
||||
}
|
||||
} else {
|
||||
register int alpha, nalpha, r, g, b;
|
||||
|
||||
r = color->red;
|
||||
g = color->green;
|
||||
b = color->blue;
|
||||
alpha = color->alpha;
|
||||
nalpha = 255 - alpha;
|
||||
|
||||
*ptr++ = (((int)*ptr * nalpha) + (r * alpha))/256;
|
||||
*ptr++ = (((int)*ptr * nalpha) + (g * alpha))/256;
|
||||
*ptr++ = (((int)*ptr * nalpha) + (b * alpha))/256;
|
||||
if (image->format == RRGBAFormat) {
|
||||
*ptr = alpha + ((int)*ptr * nalpha)/256;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
operatePixel(RImage *image, int ofs, int operation, RColor *color)
|
||||
{
|
||||
unsigned char *sr, *sg, *sb, *sa;
|
||||
register int alpha, nalpha, tmp;
|
||||
int hasAlpha = image->format == RRGBAFormat;
|
||||
|
||||
alpha = color->alpha;
|
||||
nalpha = 255 - alpha;
|
||||
|
||||
sr = image->data + ofs*(hasAlpha ? 4 : 3);
|
||||
sg = image->data + ofs*(hasAlpha ? 4 : 3) + 1;
|
||||
sb = image->data + ofs*(hasAlpha ? 4 : 3) + 2;
|
||||
sa = image->data + ofs*(hasAlpha ? 4 : 3) + 3;
|
||||
|
||||
switch (operation) {
|
||||
case RClearOperation:
|
||||
*sr = 0;
|
||||
*sg = 0;
|
||||
*sb = 0;
|
||||
if (hasAlpha)
|
||||
*sa = 0;
|
||||
break;
|
||||
case RCopyOperation:
|
||||
*sr = color->red;
|
||||
*sg = color->green;
|
||||
*sb = color->blue;
|
||||
if (hasAlpha)
|
||||
*sa = color->alpha;
|
||||
break;
|
||||
case RNormalOperation:
|
||||
if (color->alpha==255) {
|
||||
*sr = color->red;
|
||||
*sg = color->green;
|
||||
*sb = color->blue;
|
||||
if (hasAlpha)
|
||||
*sa = 255;
|
||||
} else {
|
||||
*sr = (((int)*sr * nalpha) + ((int)color->red * alpha))/256;
|
||||
*sg = (((int)*sg * nalpha) + ((int)color->green * alpha))/256;
|
||||
*sb = (((int)*sb * nalpha) + ((int)color->blue * alpha))/256;
|
||||
}
|
||||
break;
|
||||
case RAddOperation:
|
||||
tmp = color->red + *sr;
|
||||
*sr = MIN(255, tmp);
|
||||
tmp = color->green + *sg;
|
||||
*sg = MIN(255, tmp);
|
||||
tmp = color->blue + *sb;
|
||||
*sb = MIN(255, tmp);
|
||||
if (hasAlpha)
|
||||
*sa = MIN(*sa, color->alpha);
|
||||
break;
|
||||
case RSubtractOperation:
|
||||
tmp = *sr - color->red;
|
||||
*sr = MAX(0, tmp);
|
||||
tmp = *sg - color->green;
|
||||
*sg = MAX(0, tmp);
|
||||
tmp = *sb - color->blue;
|
||||
*sb = MAX(0, tmp);
|
||||
if (hasAlpha)
|
||||
*sa = MIN(*sa, color->alpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ROperatePixel(RImage *image, int operation, int x, int y, RColor *color)
|
||||
{
|
||||
int ofs;
|
||||
|
||||
assert(image!=NULL);
|
||||
assert(color!=NULL);
|
||||
assert(x >= 0 && x < image->width);
|
||||
assert(y >= 0 && y < image->height);
|
||||
|
||||
ofs = y*image->width + x;
|
||||
|
||||
operatePixel(image, ofs, operation, color);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RPutPixels(RImage *image, RPoint *points, int npoints, int mode, RColor *color)
|
||||
{
|
||||
register int x, y, i;
|
||||
|
||||
assert(image!=NULL);
|
||||
assert(points!=NULL);
|
||||
|
||||
x = y = 0;
|
||||
|
||||
for (i=0; i<npoints; i++) {
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
} else {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
RPutPixel(image, x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ROperatePixels(RImage *image, int operation, RPoint *points, int npoints,
|
||||
int mode, RColor *color)
|
||||
{
|
||||
register int x, y, i;
|
||||
|
||||
assert(image!=NULL);
|
||||
assert(points!=NULL);
|
||||
|
||||
x = y = 0;
|
||||
|
||||
for (i=0; i<npoints; i++) {
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
} else {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
ROperatePixel(image, operation, x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
clipLineInRectangle(int xmin, int ymin, int xmax, int ymax,
|
||||
int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
#define TOP (1<<0)
|
||||
#define BOT (1<<1)
|
||||
#define LEF (1<<2)
|
||||
#define RIG (1<<3)
|
||||
#define CHECK_OUT(X,Y) (((Y) > ymax ? TOP : ((Y) < ymin ? BOT : 0))\
|
||||
| ((X) > xmax ? RIG : ((X) < xmin ? LEF : 0)))
|
||||
|
||||
int ocode1, ocode2, ocode;
|
||||
int accept = 0;
|
||||
int x, y;
|
||||
|
||||
ocode1 = CHECK_OUT(*x1, *y1);
|
||||
ocode2 = CHECK_OUT(*x2, *y2);
|
||||
|
||||
for(;;) {
|
||||
if (!ocode1 && !ocode2) { /* completely inside */
|
||||
accept = 1;
|
||||
break;
|
||||
} else if (ocode1 & ocode2) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ocode1)
|
||||
ocode = ocode1;
|
||||
else
|
||||
ocode = ocode2;
|
||||
|
||||
if (ocode & TOP) {
|
||||
x = *x1 + (*x2 - *x1) * (ymax - *y1) / (*y2 - *y1);
|
||||
y = ymax;
|
||||
} else if (ocode & BOT) {
|
||||
x = *x1 + (*x2 - *x1) * (ymin - *y1) / (*y2 - *y1);
|
||||
y = ymin;
|
||||
} else if (ocode & RIG) {
|
||||
y = *y1 + (*y2 - *y1) * (xmax - *x1) / (*x2 - *x1);
|
||||
x = xmax;
|
||||
} else if (ocode & LEF) {
|
||||
y = *y1 + (*y2 - *y1) * (xmax - *x1) / (*x2 - *x1);
|
||||
x = xmin;
|
||||
}
|
||||
|
||||
if (ocode == ocode1) {
|
||||
*x1 = x;
|
||||
*y1 = y;
|
||||
ocode1 = CHECK_OUT(x, y);
|
||||
} else {
|
||||
*x2 = x;
|
||||
*y2 = y;
|
||||
ocode2 = CHECK_OUT(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
return accept;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This routine is a generic drawing routine, based on Bresenham's line
|
||||
* drawing algorithm.
|
||||
*/
|
||||
static int
|
||||
genericLine(RImage *image, int x0, int y0, int x1, int y1, RColor *color,
|
||||
int operation, int polyline)
|
||||
{
|
||||
int i, err, du, dv, du2, dv2, uofs, vofs, last;
|
||||
|
||||
assert(image!=NULL);
|
||||
|
||||
if (!clipLineInRectangle(0, 0, image->width-1, image->height-1,
|
||||
&x0, &y0, &x1, &y1))
|
||||
return True;
|
||||
|
||||
if (x0 < x1) {
|
||||
du = x1 - x0;
|
||||
uofs = 1;
|
||||
} else {
|
||||
du = x0 - x1;
|
||||
uofs = -1;
|
||||
}
|
||||
if (y0 < y1) {
|
||||
dv = y1 -y0;
|
||||
vofs = image->width;
|
||||
} else {
|
||||
dv = y0 - y1;
|
||||
vofs = -image->width;
|
||||
}
|
||||
|
||||
if (du < dv) {
|
||||
/* Swap coordinates between them, so that always du>dv */
|
||||
i = du; du = dv; dv = i;
|
||||
i = uofs; uofs = vofs; vofs = i;
|
||||
}
|
||||
|
||||
err = 0;
|
||||
du2 = du<<1;
|
||||
dv2 = dv<<1;
|
||||
last = (polyline) ? du-1 : du;
|
||||
|
||||
if (color->alpha==255 || operation==RCopyOperation) {
|
||||
unsigned char *ptr;
|
||||
|
||||
if (image->format == RRGBAFormat)
|
||||
i = (y0*image->width + x0) * 4;
|
||||
else
|
||||
i = (y0*image->width + x0) * 3;
|
||||
ptr = image->data + i;
|
||||
|
||||
for (i=0; i<=last; i++) {
|
||||
/* Draw the pixel */
|
||||
*ptr = color->red;
|
||||
*(ptr+1) = color->green;
|
||||
*(ptr+2) = color->blue;
|
||||
if (image->format == RRGBAFormat)
|
||||
*(ptr+3) = 255;
|
||||
|
||||
/* Compute error for NeXT Step */
|
||||
err += dv2;
|
||||
if (err >= du) {
|
||||
if (image->format == RRGBAFormat)
|
||||
ptr += vofs*4;
|
||||
else
|
||||
ptr += vofs*3;
|
||||
err -= du2;
|
||||
}
|
||||
if (image->format == RRGBAFormat)
|
||||
ptr += uofs*4;
|
||||
else
|
||||
ptr += uofs*3;
|
||||
}
|
||||
} else {
|
||||
register int ofs = y0*image->width + x0;
|
||||
|
||||
for (i=0; i<=last; i++) {
|
||||
/* Draw the pixel */
|
||||
operatePixel(image, ofs, operation, color);
|
||||
|
||||
/* Compute error for NeXT Step */
|
||||
err += dv2;
|
||||
if (err >= du) {
|
||||
ofs += vofs;
|
||||
err -= du2;
|
||||
}
|
||||
ofs += uofs;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mode == RALTER_PIXELS) {
|
||||
RColorOffset *cdelta = (RColorOffset*)cdata;
|
||||
register short r, g, b, a;
|
||||
|
||||
for (i=0; i<=last; i++) {
|
||||
/* Change the pixel with offset */
|
||||
r = (short)*sr + cdelta->red;
|
||||
g = (short)*sg + cdelta->green;
|
||||
b = (short)*sb + cdelta->blue;
|
||||
if (r>255) r = 255; else if (r<0) r = 0;
|
||||
if (g>255) g = 255; else if (g<0) g = 0;
|
||||
if (b>255) b = 255; else if (b<0) b = 0;
|
||||
*sr = (unsigned char) r;
|
||||
*sg = (unsigned char) g;
|
||||
*sb = (unsigned char) b;
|
||||
if (image->data[3]) {
|
||||
a = (short)*sa + cdelta->alpha;
|
||||
if (a>255) a = 255; else if (a<0) a = 0;
|
||||
*sa = (unsigned char) a;
|
||||
}
|
||||
|
||||
/* Compute error for NeXT Step */
|
||||
err += dv2;
|
||||
if (err >= du) {
|
||||
sr += vofs; sg += vofs;
|
||||
sb += vofs; sa += vofs;
|
||||
err -= du2;
|
||||
}
|
||||
sr += uofs; sg += uofs;
|
||||
sb += uofs; sa += uofs;
|
||||
}
|
||||
} else {
|
||||
RColor *color = (RColor*)cdata;
|
||||
|
||||
if (color->alpha==255) {
|
||||
for (i=0; i<=last; i++) {
|
||||
/* Draw the pixel */
|
||||
*sr = color->red;
|
||||
*sg = color->green;
|
||||
*sb = color->blue;
|
||||
if (image->data[3])
|
||||
*sa = 255;
|
||||
|
||||
/* Compute error for NeXT Step */
|
||||
err += dv2;
|
||||
if (err >= du) {
|
||||
sr += vofs; sg += vofs;
|
||||
sb += vofs; sa += vofs;
|
||||
err -= du2;
|
||||
}
|
||||
sr += uofs; sg += uofs;
|
||||
sb += uofs; sa += uofs;
|
||||
}
|
||||
} else {
|
||||
register short alpha, nalpha, r, g ,b;
|
||||
|
||||
alpha = color->alpha;
|
||||
nalpha = 255 - alpha;
|
||||
r = color->red;
|
||||
g = color->green;
|
||||
b = color->blue;
|
||||
|
||||
for (i=0; i<=last; i++) {
|
||||
/* Draw the pixel */
|
||||
*sr = (((int)*sr * nalpha) + (r * alpha))/256;
|
||||
*sg = (((int)*sg * nalpha) + (g * alpha))/256;
|
||||
*sb = (((int)*sb * nalpha) + (b * alpha))/256;
|
||||
if (image->data[3])
|
||||
*sa = alpha + ((int)*sa * nalpha)/256;
|
||||
|
||||
/* Compute error for NeXT Step */
|
||||
err += dv2;
|
||||
if (err >= du) {
|
||||
sr += vofs; sg += vofs;
|
||||
sb += vofs; sa += vofs;
|
||||
err -= du2;
|
||||
}
|
||||
sr += uofs; sg += uofs;
|
||||
sb += uofs; sa += uofs;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
RDrawLine(RImage *image, int x0, int y0, int x1, int y1, RColor *color)
|
||||
{
|
||||
return genericLine(image, x0, y0, x1, y1, color, RNormalOperation, False);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ROperateLine(RImage *image, int operation, int x0, int y0, int x1,
|
||||
int y1, RColor *color)
|
||||
{
|
||||
return genericLine(image, x0, y0, x1, y1, color, operation, False);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RDrawLines(RImage *image, RPoint *points, int npoints, int mode, RColor *color)
|
||||
{
|
||||
register int x1, y1, x2, y2, i;
|
||||
|
||||
assert(points!=NULL);
|
||||
|
||||
if (npoints==0)
|
||||
return;
|
||||
|
||||
x1 = points[0].x;
|
||||
y1 = points[0].y;
|
||||
x2 = y2 = 0;
|
||||
|
||||
for (i=1; i<npoints-1; i++) {
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
} else {
|
||||
x2 += points[i-1].x;
|
||||
y2 += points[i-1].y;
|
||||
}
|
||||
/* Don't draw pixels at junction points twice */
|
||||
genericLine(image, x1, y1, x2, y2, color, RNormalOperation, True);
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
i = npoints-1; /* last point */
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
} else {
|
||||
x2 += points[i-1].x;
|
||||
y2 += points[i-1].y;
|
||||
}
|
||||
i = (points[0].x==x2 && points[0].y==y2 && npoints>1);
|
||||
genericLine(image, x1, y1, x2, y2, color, RNormalOperation, i);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ROperateLines(RImage *image, int operation, RPoint *points,
|
||||
int npoints, int mode, RColor *color)
|
||||
{
|
||||
register int x1, y1, x2, y2, i;
|
||||
|
||||
assert(points!=NULL);
|
||||
|
||||
if (npoints==0)
|
||||
return;
|
||||
|
||||
x1 = points[0].x;
|
||||
y1 = points[0].y;
|
||||
x2 = y2 = 0;
|
||||
|
||||
for (i=1; i<npoints-1; i++) {
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
} else {
|
||||
x2 += points[i-1].x;
|
||||
y2 += points[i-1].y;
|
||||
}
|
||||
/* Don't draw pixels at junction points twice */
|
||||
genericLine(image, x1, y1, x2, y2, color, operation, True);
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
i = npoints-1; /* last point */
|
||||
if (mode == RAbsoluteCoordinates) {
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
} else {
|
||||
x2 += points[i-1].x;
|
||||
y2 += points[i-1].y;
|
||||
}
|
||||
i = (points[0].x==x2 && points[0].y==y2 && npoints>1);
|
||||
genericLine(image, x1, y1, x2, y2, color, operation, i);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RDrawSegments(RImage *image, RSegment *segs, int nsegs, RColor *color)
|
||||
{
|
||||
register int i;
|
||||
|
||||
assert(segs!=NULL);
|
||||
|
||||
for (i=0; i<nsegs; i++) {
|
||||
genericLine(image, segs->x1, segs->y1, segs->x2, segs->y2, color,
|
||||
RNormalOperation, False);
|
||||
segs++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ROperateSegments(RImage *image, int operation, RSegment *segs,
|
||||
int nsegs, RColor *color)
|
||||
{
|
||||
register int i;
|
||||
|
||||
assert(segs!=NULL);
|
||||
|
||||
for (i=0; i<nsegs; i++) {
|
||||
genericLine(image, segs->x1, segs->y1, segs->x2, segs->y2, color,
|
||||
operation, False);
|
||||
segs++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,488 +0,0 @@
|
|||
/* gradient.c - renders gradients
|
||||
*
|
||||
* Raster graphics library
|
||||
*
|
||||
* Copyright (c) 1997-2000 Alfredo K. Kojima
|
||||
* Copyright (c) 1998-2000 Dan Pascu
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "x11/wraster.h"
|
||||
|
||||
|
||||
static RImage *renderHGradient(unsigned width, unsigned height,
|
||||
int r0, int g0, int b0,
|
||||
int rf, int gf, int bf);
|
||||
static RImage *renderVGradient(unsigned width, unsigned height,
|
||||
int r0, int g0, int b0,
|
||||
int rf, int gf, int bf);
|
||||
static RImage *renderDGradient(unsigned width, unsigned height,
|
||||
int r0, int g0, int b0,
|
||||
int rf, int gf, int bf);
|
||||
|
||||
static RImage *renderMHGradient(unsigned width, unsigned height,
|
||||
RColor **colors, int count);
|
||||
static RImage *renderMVGradient(unsigned width, unsigned height,
|
||||
RColor **colors, int count);
|
||||
static RImage *renderMDGradient(unsigned width, unsigned height,
|
||||
RColor **colors, int count);
|
||||
|
||||
RImage*
|
||||
RRenderMultiGradient(unsigned width, unsigned height, RColor **colors, int style)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
while (colors[count]!=NULL) count++;
|
||||
|
||||
if (count > 2) {
|
||||
switch (style) {
|
||||
case RHorizontalGradient:
|
||||
return renderMHGradient(width, height, colors, count);
|
||||
case RVerticalGradient:
|
||||
return renderMVGradient(width, height, colors, count);
|
||||
case RDiagonalGradient:
|
||||
return renderMDGradient(width, height, colors, count);
|
||||
}
|
||||
} else if (count > 1) {
|
||||
return RRenderGradient(width, height, colors[0], colors[1], style);
|
||||
} else if (count > 0) {
|
||||
return RRenderGradient(width, height, colors[0], colors[0], style);
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RImage*
|
||||
RRenderGradient(unsigned width, unsigned height, RColor *from, RColor *to,
|
||||
int style)
|
||||
{
|
||||
switch (style) {
|
||||
case RHorizontalGradient:
|
||||
return renderHGradient(width, height, from->red, from->green,
|
||||
from->blue, to->red, to->green, to->blue);
|
||||
case RVerticalGradient:
|
||||
return renderVGradient(width, height, from->red, from->green,
|
||||
from->blue, to->red, to->green, to->blue);
|
||||
|
||||
case RDiagonalGradient:
|
||||
return renderDGradient(width, height, from->red, from->green,
|
||||
from->blue, to->red, to->green, to->blue);
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* renderHGradient--
|
||||
* Renders a horizontal linear gradient of the specified size in the
|
||||
* RImage format with a border of the specified type.
|
||||
*
|
||||
* Returns:
|
||||
* A 24bit RImage with the gradient (no alpha channel).
|
||||
*
|
||||
* Side effects:
|
||||
* None
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
static RImage*
|
||||
renderHGradient(unsigned width, unsigned height, int r0, int g0, int b0,
|
||||
int rf, int gf, int bf)
|
||||
{
|
||||
int i;
|
||||
unsigned long r, g, b, dr, dg, db;
|
||||
RImage *image;
|
||||
unsigned char *ptr;
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
ptr = image->data;
|
||||
|
||||
r = r0 << 16;
|
||||
g = g0 << 16;
|
||||
b = b0 << 16;
|
||||
|
||||
dr = ((rf-r0)<<16)/(int)width;
|
||||
dg = ((gf-g0)<<16)/(int)width;
|
||||
db = ((bf-b0)<<16)/(int)width;
|
||||
/* render the first line */
|
||||
for (i=0; i<width; i++) {
|
||||
*(ptr++) = (unsigned char)(r>>16);
|
||||
*(ptr++) = (unsigned char)(g>>16);
|
||||
*(ptr++) = (unsigned char)(b>>16);
|
||||
r += dr;
|
||||
g += dg;
|
||||
b += db;
|
||||
}
|
||||
|
||||
/* copy the first line to the other lines */
|
||||
for (i=1; i<height; i++) {
|
||||
memcpy(&(image->data[i*width*3]), image->data, width*3);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* renderVGradient--
|
||||
* Renders a vertical linear gradient of the specified size in the
|
||||
* RImage format with a border of the specified type.
|
||||
*
|
||||
* Returns:
|
||||
* A 24bit RImage with the gradient (no alpha channel).
|
||||
*
|
||||
* Side effects:
|
||||
* None
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
static RImage*
|
||||
renderVGradient(unsigned width, unsigned height, int r0, int g0, int b0,
|
||||
int rf, int gf, int bf)
|
||||
{
|
||||
int i, j;
|
||||
unsigned long r, g, b, dr, dg, db;
|
||||
RImage *image;
|
||||
unsigned char *ptr;
|
||||
unsigned int *iptr;
|
||||
unsigned char rr, gg, bb;
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
iptr = (unsigned int*)ptr = image->data;
|
||||
|
||||
r = r0<<16;
|
||||
g = g0<<16;
|
||||
b = b0<<16;
|
||||
|
||||
dr = ((rf-r0)<<16)/(int)height;
|
||||
dg = ((gf-g0)<<16)/(int)height;
|
||||
db = ((bf-b0)<<16)/(int)height;
|
||||
|
||||
for (i=0; i<height; i++) {
|
||||
rr = r>>16;
|
||||
gg = g>>16;
|
||||
bb = b>>16;
|
||||
for (j=0; j<width/8; j++) {
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
*(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
}
|
||||
switch (width%8) {
|
||||
case 7: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 6: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 5: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 4: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 3: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 2: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
case 1: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
|
||||
}
|
||||
r+=dr;
|
||||
g+=dg;
|
||||
b+=db;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* renderDGradient--
|
||||
* Renders a diagonal linear gradient of the specified size in the
|
||||
* RImage format with a border of the specified type.
|
||||
*
|
||||
* Returns:
|
||||
* A 24bit RImage with the gradient (no alpha channel).
|
||||
*
|
||||
* Side effects:
|
||||
* None
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static RImage*
|
||||
renderDGradient(unsigned width, unsigned height, int r0, int g0, int b0,
|
||||
int rf, int gf, int bf)
|
||||
{
|
||||
RImage *image, *tmp;
|
||||
int j;
|
||||
float a, offset;
|
||||
char *ptr;
|
||||
|
||||
if (width == 1)
|
||||
return renderVGradient(width, height, r0, g0, b0, rf, gf, bf);
|
||||
else if (height == 1)
|
||||
return renderHGradient(width, height, r0, g0, b0, rf, gf, bf);
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmp = renderHGradient(2*width-1, 1, r0, g0, b0, rf, gf, bf);
|
||||
if (!tmp) {
|
||||
RDestroyImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = tmp->data;
|
||||
|
||||
a = ((float)(width - 1))/((float)(height - 1));
|
||||
width = width * 3;
|
||||
|
||||
/* copy the first line to the other lines with corresponding offset */
|
||||
for (j=0, offset=0.0; j<width*height; j += width) {
|
||||
memcpy(&(image->data[j]), &ptr[3*(int)offset], width);
|
||||
offset += a;
|
||||
}
|
||||
|
||||
RDestroyImage(tmp);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
static RImage*
|
||||
renderMHGradient(unsigned width, unsigned height, RColor **colors, int count)
|
||||
{
|
||||
int i, j, k;
|
||||
unsigned long r, g, b, dr, dg, db;
|
||||
RImage *image;
|
||||
unsigned char *ptr;
|
||||
unsigned width2;
|
||||
|
||||
|
||||
assert(count > 2);
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
ptr = image->data;
|
||||
|
||||
if (count > width)
|
||||
count = width;
|
||||
|
||||
if (count > 1)
|
||||
width2 = width/(count-1);
|
||||
else
|
||||
width2 = width;
|
||||
|
||||
k = 0;
|
||||
|
||||
r = colors[0]->red << 16;
|
||||
g = colors[0]->green << 16;
|
||||
b = colors[0]->blue << 16;
|
||||
|
||||
/* render the first line */
|
||||
for (i=1; i<count; i++) {
|
||||
dr = ((int)(colors[i]->red - colors[i-1]->red) <<16)/(int)width2;
|
||||
dg = ((int)(colors[i]->green - colors[i-1]->green)<<16)/(int)width2;
|
||||
db = ((int)(colors[i]->blue - colors[i-1]->blue) <<16)/(int)width2;
|
||||
for (j=0; j<width2; j++) {
|
||||
*ptr++ = (unsigned char)(r>>16);
|
||||
*ptr++ = (unsigned char)(g>>16);
|
||||
*ptr++ = (unsigned char)(b>>16);
|
||||
r += dr;
|
||||
g += dg;
|
||||
b += db;
|
||||
k++;
|
||||
}
|
||||
r = colors[i]->red << 16;
|
||||
g = colors[i]->green << 16;
|
||||
b = colors[i]->blue << 16;
|
||||
}
|
||||
for (j=k; j<width; j++) {
|
||||
*ptr++ = (unsigned char)(r>>16);
|
||||
*ptr++ = (unsigned char)(g>>16);
|
||||
*ptr++ = (unsigned char)(b>>16);
|
||||
}
|
||||
|
||||
/* copy the first line to the other lines */
|
||||
for (i=1; i<height; i++) {
|
||||
memcpy(&(image->data[i*width*3]), image->data, width*3);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static RImage*
|
||||
renderMVGradient(unsigned width, unsigned height, RColor **colors, int count)
|
||||
{
|
||||
int i, j, k;
|
||||
unsigned long r, g, b, dr, dg, db;
|
||||
RImage *image;
|
||||
unsigned char *ptr, *tmp;
|
||||
unsigned height2;
|
||||
int x;
|
||||
unsigned char rr, gg, bb;
|
||||
|
||||
|
||||
assert(count > 2);
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
ptr = image->data;
|
||||
|
||||
if (count > height)
|
||||
count = height;
|
||||
|
||||
if (count > 1)
|
||||
height2 = height/(count-1);
|
||||
else
|
||||
height2 = height;
|
||||
|
||||
k = 0;
|
||||
|
||||
r = colors[0]->red << 16;
|
||||
g = colors[0]->green << 16;
|
||||
b = colors[0]->blue << 16;
|
||||
|
||||
for (i=1; i<count; i++) {
|
||||
dr = ((int)(colors[i]->red - colors[i-1]->red) <<16)/(int)height2;
|
||||
dg = ((int)(colors[i]->green - colors[i-1]->green)<<16)/(int)height2;
|
||||
db = ((int)(colors[i]->blue - colors[i-1]->blue) <<16)/(int)height2;
|
||||
|
||||
for (j=0; j<height2; j++) {
|
||||
rr = r>>16;
|
||||
gg = g>>16;
|
||||
bb = b>>16;
|
||||
|
||||
for (x=0; x<width/4; x++) {
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
}
|
||||
switch (width%4) {
|
||||
case 3: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
case 2: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
case 1: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
}
|
||||
r += dr;
|
||||
g += dg;
|
||||
b += db;
|
||||
k++;
|
||||
}
|
||||
r = colors[i]->red << 16;
|
||||
g = colors[i]->green << 16;
|
||||
b = colors[i]->blue << 16;
|
||||
}
|
||||
|
||||
rr = r>>16;
|
||||
gg = g>>16;
|
||||
bb = b>>16;
|
||||
|
||||
if (k<height) {
|
||||
tmp = ptr;
|
||||
for (x=0; x<width/4; x++) {
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
*ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
}
|
||||
switch (width%4) {
|
||||
case 3: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
case 2: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
case 1: *ptr++ = rr; *ptr++ = gg; *ptr++ = bb;
|
||||
default: break;
|
||||
}
|
||||
|
||||
for (j=k+1; j<height; j++) {
|
||||
memcpy(ptr, tmp, width*3);
|
||||
ptr += width*3;
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
static RImage*
|
||||
renderMDGradient(unsigned width, unsigned height, RColor **colors, int count)
|
||||
{
|
||||
RImage *image, *tmp;
|
||||
float a, offset;
|
||||
int j;
|
||||
unsigned char *ptr;
|
||||
|
||||
assert(count > 2);
|
||||
|
||||
if (width == 1)
|
||||
return renderMVGradient(width, height, colors, count);
|
||||
else if (height == 1)
|
||||
return renderMHGradient(width, height, colors, count);
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
if (!image) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (count > width)
|
||||
count = width;
|
||||
if (count > height)
|
||||
count = height;
|
||||
|
||||
if (count > 2)
|
||||
tmp = renderMHGradient(2*width-1, 1, colors, count);
|
||||
else
|
||||
tmp = renderHGradient(2*width-1, 1, colors[0]->red<<8,
|
||||
colors[0]->green<<8, colors[0]->blue<<8,
|
||||
colors[1]->red<<8, colors[1]->green<<8,
|
||||
colors[1]->blue<<8);
|
||||
|
||||
if (!tmp) {
|
||||
RDestroyImage(image);
|
||||
return NULL;
|
||||
}
|
||||
ptr = tmp->data;
|
||||
|
||||
a = ((float)(width - 1))/((float)(height - 1));
|
||||
width = width * 3;
|
||||
|
||||
/* copy the first line to the other lines with corresponding offset */
|
||||
for (j=0, offset=0; j<width*height; j += width) {
|
||||
memcpy(&(image->data[j]), &ptr[3*(int)offset], width);
|
||||
offset += a;
|
||||
}
|
||||
RDestroyImage(tmp);
|
||||
return image;
|
||||
}
|
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
* Raster graphics library
|
||||
*
|
||||
* Copyright (c) 1997-2000 Alfredo K. Kojima
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "x11/wraster.h"
|
||||
|
||||
|
||||
void
|
||||
RBevelImage(RImage *image, int bevel_type)
|
||||
{
|
||||
RColor color;
|
||||
RColor cdelta;
|
||||
int w, h;
|
||||
|
||||
if (image->width<3 || image->height<3)
|
||||
return;
|
||||
|
||||
w = image->width;
|
||||
h = image->height;
|
||||
if (bevel_type>0) { /* raised */
|
||||
/* top */
|
||||
cdelta.alpha = 0;
|
||||
cdelta.red = cdelta.green = cdelta.blue = 80;
|
||||
ROperateLine(image, RAddOperation, 0, 0, w-1, 0, &cdelta);
|
||||
if (bevel_type==RBEV_RAISED3 && w>3)
|
||||
ROperateLine(image, RAddOperation, 1, 1, w-3, 1,&cdelta);
|
||||
|
||||
/* left */
|
||||
ROperateLine(image, RAddOperation, 0, 1, 0, h-1, &cdelta);
|
||||
if (bevel_type==RBEV_RAISED3 && h>3)
|
||||
ROperateLine(image, RAddOperation, 1, 2, 1, h-3, &cdelta);
|
||||
|
||||
/* bottom */
|
||||
color.alpha = 255;
|
||||
color.red = color.green = color.blue = 0;
|
||||
cdelta.red = cdelta.green = cdelta.blue = 40;
|
||||
if (bevel_type==RBEV_RAISED2 || bevel_type==RBEV_RAISED3) {
|
||||
ROperateLine(image, RSubtractOperation, 0, h-2, w-3,
|
||||
h-2, &cdelta);
|
||||
RDrawLine(image, 0, h-1, w-1, h-1, &color);
|
||||
} else {
|
||||
ROperateLine(image, RSubtractOperation, 0, h-1, w-1, h-1,
|
||||
&cdelta);
|
||||
}
|
||||
|
||||
/* right */
|
||||
if (bevel_type==RBEV_RAISED2 || bevel_type==RBEV_RAISED3) {
|
||||
ROperateLine(image, RSubtractOperation, w-2, 0, w-2, h-2,
|
||||
&cdelta);
|
||||
RDrawLine(image, w-1, 0, w-1, h-2, &color);
|
||||
} else {
|
||||
ROperateLine(image, RSubtractOperation, w-1, 0, w-1, h-2,
|
||||
&cdelta);
|
||||
}
|
||||
} else { /* sunken */
|
||||
cdelta.alpha = 0;
|
||||
cdelta.red = cdelta.green = cdelta.blue = 40;
|
||||
ROperateLine(image, RSubtractOperation, 0, 0, w-1, 0,
|
||||
&cdelta); /* top */
|
||||
ROperateLine(image, RSubtractOperation, 0, 1, 0, h-1,
|
||||
&cdelta); /* left */
|
||||
cdelta.red = cdelta.green = cdelta.blue = 80;
|
||||
ROperateLine(image, RAddOperation, 0, h-1, w-1, h-1, &cdelta); /* bottom */
|
||||
ROperateLine(image, RAddOperation, w-1, 0, w-1, h-2, &cdelta); /* right */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RClearImage(RImage *image, RColor *color)
|
||||
{
|
||||
if (image->format == RRGBAFormat) {
|
||||
unsigned char *d = image->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < image->width; i++) {
|
||||
*d++ = color->red;
|
||||
*d++ = color->green;
|
||||
*d++ = color->blue;
|
||||
*d++ = color->alpha;
|
||||
}
|
||||
for (i = 1; i < image->height; i++, d += image->width*4) {
|
||||
memcpy(d, image->data, image->width*4);
|
||||
}
|
||||
} else {
|
||||
unsigned char *d = image->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < image->width; i++) {
|
||||
*d++ = color->red;
|
||||
*d++ = color->green;
|
||||
*d++ = color->blue;
|
||||
}
|
||||
for (i = 1; i < image->height; i++, d += image->width*3) {
|
||||
memcpy(d, image->data, image->width*3);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (color->alpha==255) {
|
||||
if (image->format == RRGBAFormat) {
|
||||
unsigned char *d = image->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < image->width; i++) {
|
||||
*d++ = color->red;
|
||||
*d++ = color->green;
|
||||
*d++ = color->blue;
|
||||
*d++ = 0xff;
|
||||
}
|
||||
for (i = 1; i < image->height; i++, d += image->width*4) {
|
||||
memcpy(d, image->data, image->width*4);
|
||||
}
|
||||
} else {
|
||||
unsigned char *d = image->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < image->width; i++) {
|
||||
*d++ = color->red;
|
||||
*d++ = color->green;
|
||||
*d++ = color->blue;
|
||||
}
|
||||
for (i = 1; i < image->height; i++, d += image->width*3) {
|
||||
memcpy(d, image->data, image->width*3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int bytes = image->width*image->height;
|
||||
int i;
|
||||
unsigned char *d;
|
||||
int alpha, nalpha, r, g, b;
|
||||
|
||||
d = image->data;
|
||||
|
||||
alpha = color->alpha;
|
||||
r = color->red * alpha;
|
||||
g = color->green * alpha;
|
||||
b = color->blue * alpha;
|
||||
nalpha = 255 - alpha;
|
||||
|
||||
for (i=0; i<bytes; i++) {
|
||||
*d = (((int)*d * nalpha) + r)/256;
|
||||
d++;
|
||||
*d = (((int)*d * nalpha) + g)/256;
|
||||
d++;
|
||||
*d = (((int)*d * nalpha) + b)/256;
|
||||
d++;
|
||||
if (image->format == RRGBAFormat) {
|
||||
d++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const char*
|
||||
RMessageForError(int errorCode)
|
||||
{
|
||||
switch (errorCode) {
|
||||
case RERR_NONE:
|
||||
return "no error";
|
||||
|
||||
case RERR_OPEN:
|
||||
return "could not open file";
|
||||
|
||||
case RERR_READ:
|
||||
return "error reading from file";
|
||||
|
||||
case RERR_WRITE:
|
||||
return "error writing to file";
|
||||
|
||||
case RERR_NOMEMORY:
|
||||
return "out of memory";
|
||||
|
||||
case RERR_NOCOLOR:
|
||||
return "out of color cells";
|
||||
|
||||
case RERR_BADIMAGEFILE:
|
||||
return "invalid or corrupted image file";
|
||||
|
||||
case RERR_BADFORMAT:
|
||||
return "the image format in the file is not supported and can't be loaded";
|
||||
|
||||
case RERR_BADINDEX:
|
||||
return "image file does not contain requested image index";
|
||||
|
||||
case RERR_BADVISUALID:
|
||||
return "request for an invalid visual ID";
|
||||
|
||||
case RERR_STDCMAPFAIL:
|
||||
return "failed to create standard colormap";
|
||||
|
||||
case RERR_XERROR:
|
||||
return "internal X error";
|
||||
|
||||
default:
|
||||
case RERR_INTERNAL:
|
||||
return "internal error";
|
||||
}
|
||||
}
|
|
@ -1537,6 +1537,11 @@ typedef enum {
|
|||
}
|
||||
}
|
||||
|
||||
- (void) DPSsetmiterlimit: (float)limit
|
||||
{
|
||||
/* Do nothing. X11 does its own thing and doesn't give us a choice */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Paint operations */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in a new issue