2 * libwmfun - WindowMaker texture function library
3 * Copyright (C) 1999 Tobias Gloth
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 * Revision 1.2 2001/04/21 07:12:30 dan
29 * - Added retain/release mechanism to RImage by adding RRetainImage() and
30 * RReleaseImage(). RDestroyImage() is an alias to RReleaseImage() now, but
31 * will be removed in a future release because it no longer fits with the
32 * semantics. Will be kept for a while to allow a smoother transition.
33 * More about in wrlib/NEWS
40 * 1. Renamed WMSetApplicationIconImage(), WMGetApplicationIconImage() and
41 * WMSetWindowMiniwindowImage() to respectively WMSetApplicationIconPixmap(),
42 * WMGetApplicationIconPixmap() and WMSetWindowMiniwindowPixmap()
43 * They operate on a WMPixmap which is practically an X Pixmap with no alpha
44 * channel information and the new name is more suggestive and also leaves
45 * room for the new functions added for operating on images with alpha info.
46 * 2. Added WMSetApplicationIconImage() and WMGetApplicationIconImage() which
47 * operate on an RImage and store alpha information too.
48 * 3. Added WMGetApplicationIconBlendedPixmap() which will take the image with
49 * alpha set by WMSetApplicationIconImage() and will blend it with a color.
50 * If color is NULL it will blend using the default panel color (#aeaaae)
51 * All these changes will allow WINGs to handle images with alpha blending
52 * correctly in panels and wherever else needed. More about in WINGs/NEWS.
53 * - updated panels to use the newly available RImages if present and fallback
54 * to old WMPixmaps if not, to properly show alpha blended images.
55 * - replaced some still left malloc's with wmalloc's.
60 * - Fixed wrong mapping position of the "Docked Applications Panel" for some
62 * - Smoother animation for the smiley =)
63 * - Made images with alpha blending be shown correctly in the panels and the
65 * - The icon image set to be shown in panels ("Logo.WMPanel") will be
66 * automatically updated if its entry in WMWindowAttributes changes (without
67 * a need to restart as until now).
72 * If you are developing applications with one of libwraster or libWINGs
73 * then you should look to wrlib/NEWS and WINGs/NEWS to see what changed
74 * and how should you update your code.
76 * Revision 1.1 2000/12/03 18:58:41 id
77 * initiate plugins branch
79 * Revision 1.1.1.1 1999/02/21 17:16:47 gloth
91 RImage
*fade (int argc
, char **argv
, int width
, int height
, int relief
) {
93 int from
[3] = { 0x00, 0x00, 0x00 };
94 int to
[3] = { 0xff, 0xff, 0xff };
101 int c
, done
, option_index
= 0;
104 for (done
=0; !done
; ) {
105 static struct option long_options
[] = {
111 c
= getopt_long (argc
, argv
, "f:t:",
112 long_options
, &option_index
);
119 if (!parse_color (optarg
, from
)) {
120 error ("invalid color: %s\n", optarg
);
125 if (!parse_color (optarg
, to
)) {
126 error ("invalid color: %s\n", optarg
);
139 if (!start_image ("fade", argc
, 0, 1, width
, height
, &image
)) {
143 this = (int *) malloc (width
* sizeof (int));
144 last
= (int *) malloc (width
* sizeof (int));
145 if (!this || !last
) {
146 RReleaseImage (image
);
152 for (i
=0; i
<width
; i
++) {
156 factor
= pow (0.2, 1.0 / height
);
157 delta
= (factor
< 0.5) ? 2.0 * factor
: 2.0 * (1.0 - factor
);
162 for (j
=0; j
<height
; j
++) {
163 memcpy (last
, this, width
* sizeof (int));
164 for (i
=0; i
<width
; i
++) {
166 int k
= i
+ random_int (3) - 1;
167 double f
= factor
+ random_double (delta
) - delta
/2.0;
176 this[i
] = (int) (f
* last
[k
]);
177 interpolate_color (output
, from
, to
, this[i
]);
181 if (RRGBAFormat
==image
->format
)