2 * Raster graphics library
4 * Copyright (c) 1997 Alfredo K. Kojima
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 RBevelImage(RImage
*image
, int bevel_type
)
38 if (image
->width
<3 || image
->height
<3)
43 if (bevel_type
>0) { /* raised */
46 cdelta
.red
= cdelta
.green
= cdelta
.blue
= 80;
47 ROperateLine(image
, RAddOperation
, 0, 0, w
-1, 0, &cdelta
);
48 if (bevel_type
==RBEV_RAISED3
&& w
>3)
49 ROperateLine(image
, RAddOperation
, 1, 1, w
-3, 1,&cdelta
);
52 ROperateLine(image
, RAddOperation
, 0, 1, 0, h
-1, &cdelta
);
53 if (bevel_type
==RBEV_RAISED3
&& h
>3)
54 ROperateLine(image
, RAddOperation
, 1, 2, 1, h
-3, &cdelta
);
58 color
.red
= color
.green
= color
.blue
= 0;
59 cdelta
.red
= cdelta
.green
= cdelta
.blue
= 40;
60 if (bevel_type
==RBEV_RAISED2
|| bevel_type
==RBEV_RAISED3
) {
61 ROperateLine(image
, RSubtractOperation
, 0, h
-2, w
-3,
63 RDrawLine(image
, 0, h
-1, w
-1, h
-1, &color
);
65 ROperateLine(image
, RSubtractOperation
, 0, h
-1, w
-1, h
-1,
70 if (bevel_type
==RBEV_RAISED2
|| bevel_type
==RBEV_RAISED3
) {
71 ROperateLine(image
, RSubtractOperation
, w
-2, 0, w
-2, h
-2,
73 RDrawLine(image
, w
-1, 0, w
-1, h
-2, &color
);
75 ROperateLine(image
, RSubtractOperation
, w
-1, 0, w
-1, h
-2,
80 cdelta
.red
= cdelta
.green
= cdelta
.blue
= 40;
81 ROperateLine(image
, RSubtractOperation
, 0, 0, w
-1, 0,
83 ROperateLine(image
, RSubtractOperation
, 0, 1, 0, h
-1,
85 cdelta
.red
= cdelta
.green
= cdelta
.blue
= 80;
86 ROperateLine(image
, RAddOperation
, 0, h
-1, w
-1, h
-1, &cdelta
); /* bottom */
87 ROperateLine(image
, RAddOperation
, w
-1, 0, w
-1, h
-2, &cdelta
); /* right */
93 RClearImage(RImage
*image
, RColor
*color
)
97 bytes
= image
->width
*image
->height
;
99 if (color
->alpha
==255) {
100 memset(image
->data
[0], color
->red
, bytes
);
101 memset(image
->data
[1], color
->green
, bytes
);
102 memset(image
->data
[2], color
->blue
, bytes
);
104 memset(image
->data
[3], 0xff, bytes
);
107 unsigned char *dr
, *dg
, *db
;
108 int alpha
, nalpha
, r
, g
, b
;
114 alpha
= color
->alpha
;
115 r
= color
->red
* alpha
;
116 g
= color
->green
* alpha
;
117 b
= color
->blue
* alpha
;
118 nalpha
= 255 - alpha
;
120 for (i
=0; i
<bytes
; i
++) {
121 *dr
= (((int)*dr
* nalpha
) + r
)/256;
122 *dg
= (((int)*dg
* nalpha
) + g
)/256;
123 *db
= (((int)*db
* nalpha
) + b
)/256;
131 RMessageForError(int errorCode
)
138 return "could not open file";
141 return "error reading from file";
144 return "error writing to file";
147 return "out of memory";
150 return "out of color cells";
152 case RERR_BADIMAGEFILE
:
153 return "invalid or corrupted image file";
156 return "the image format in the file is not supported and can't be loaded";
159 return "image file does not contain requested image index";
161 case RERR_BADVISUALID
:
162 return "request for an invalid visual ID";
165 return "internal X error";
169 return "internal error";