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 */
94 RClearImage(RImage
*image
, RColor
*color
)
98 bytes
= image
->width
*image
->height
;
100 if (color
->alpha
==255) {
101 memset(image
->data
[0], color
->red
, bytes
);
102 memset(image
->data
[1], color
->green
, bytes
);
103 memset(image
->data
[2], color
->blue
, bytes
);
105 memset(image
->data
[3], 0xff, bytes
);
108 unsigned char *dr
, *dg
, *db
;
109 int alpha
, nalpha
, r
, g
, b
;
118 alpha
= color
->alpha
;
119 nalpha
= 255 - alpha
;
121 for (i
=0; i
<bytes
; i
++) {
122 *dr
= (((int)*dr
* nalpha
) + (r
* alpha
))/256;
123 *dg
= (((int)*dg
* nalpha
) + (g
* alpha
))/256;
124 *db
= (((int)*db
* nalpha
) + (b
* alpha
))/256;