Package: xscreensaver
Version: 4.21-5
Severity: wishlist
I added a new option to the screen hack ripples(6x). It is -grayscale
which converts the grabbed screen image to grayscale. Patch attached.
Note that this option is different from -mono which means "only 2 colors
in the screen".
-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.4.27-2-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)
Versions of packages xscreensaver depends on:
ii libatk1.0-0 1.8.0-4 The ATK accessibility toolkit
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libglade2-0 1:2.4.2-2 library to load .glade files at ru
ii libglib2.0-0 2.6.4-1 The GLib library of C routines
ii libgtk2.0-0 2.6.4-3 The GTK+ graphical user interface
ii libice6 4.3.0.dfsg.1-14 Inter-Client Exchange library
ii libjpeg62 6b-10 The Independent JPEG Group's JPEG
ii libpam0g 0.76-22 Pluggable Authentication Modules l
ii libpango1.0-0 1.8.1-1 Layout and rendering of internatio
ii libsm6 4.3.0.dfsg.1-14 X Window System Session Management
ii libx11-6 4.3.0.dfsg.1-14 X Window System protocol client li
ii libxext6 4.3.0.dfsg.1-14 X Window System miscellaneous exte
ii libxml2 2.6.16-7 GNOME XML library
ii libxmu6 4.3.0.dfsg.1-14 X Window System miscellaneous util
ii libxpm4 4.3.0.dfsg.1-14 X pixmap library
ii libxrandr2 4.3.0.dfsg.1-14 X Window System Resize, Rotate and
ii libxrender1 0.8.3-7 X Rendering Extension client libra
ii libxt6 4.3.0.dfsg.1-14 X Toolkit Intrinsics
ii xlibs 4.3.0.dfsg.1-14 X Keyboard Extension (XKB) configu
ii zlib1g 1:1.2.2-4 compression library - runtime
-- no debconf information
unchanged:
--- xscreensaver-4.21-unmodified/hacks/ripples.c 2005-02-12
08:32:43.000000000 +0900
+++ xscreensaver-4.21/hacks/ripples.c 2005-09-29 02:50:21.000000000 +0900
@@ -99,6 +99,9 @@
- (((x)>>3)&0x11111111))
+static Bool grayscale_p;
+static unsigned long grayscale(unsigned long color);
+
/* ------------------------------------------- */
@@ -197,13 +200,13 @@
if (dirty[pixel] > 0) {
XPutPixel(buffer_map, (across<<1), (down<<1),
- XGetPixel(orig_map, (across<<1) + gradx, (down<<1) + grady));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx, (down<<1)
+ grady)));
XPutPixel(buffer_map, (across<<1)+1,(down<<1),
- XGetPixel(orig_map, (across<<1) + gradx1,(down<<1) + grady));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx1,(down<<1)
+ grady)));
XPutPixel(buffer_map, (across<<1), (down<<1)+1,
- XGetPixel(orig_map, (across<<1) + gradx, (down<<1) +
grady1));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx, (down<<1)
+ grady1)));
XPutPixel(buffer_map, (across<<1)+1,(down<<1)+1,
- XGetPixel(orig_map, (across<<1) + gradx1,(down<<1) +
grady1));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx1,(down<<1)
+ grady1)));
}
}
}
@@ -257,6 +260,48 @@
}
+static unsigned long
+grayscale(unsigned long color)
+{
+ int red;
+ int green;
+ int blue;
+ int gray_r;
+ int gray_g;
+ int gray_b;
+
+ if (!grayscale_p)
+ return color;
+ if (!transparent)
+ return color;
+
+ red = ((color >> rshift) & rmask);
+ green = ((color >> gshift) & gmask);
+ blue = ((color >> bshift) & bmask);
+
+ gray_r = rmask * (red + green + blue) / (rmask + gmask + bmask);
+ if (gray_r < 0)
+ gray_r = 0;
+ if (gray_r > rmask)
+ gray_r = rmask;
+
+ gray_g = gmask * (red + green + blue) / (rmask + gmask + bmask);
+ if (gray_g < 0)
+ gray_g = 0;
+ if (gray_g > gmask)
+ gray_g = gmask;
+
+ gray_b = bmask * (red + green + blue) / (rmask + gmask + bmask);
+ if (gray_b < 0)
+ gray_b = 0;
+ if (gray_b > bmask)
+ gray_b = bmask;
+
+ return ((unsigned long)
+ ((gray_r << rshift) | (gray_g << gshift) | (gray_b << bshift)));
+}
+
+
static void
draw_transparent_light(short *src)
{
@@ -310,23 +355,23 @@
if (dx != 0) {
XPutPixel(buffer_map, (across<<1), (down<<1),
- bright(dx, XGetPixel(orig_map, (across<<1) + gradx,
(down<<1) + grady)));
+ bright(dx, grayscale(XGetPixel(orig_map, (across<<1) +
gradx, (down<<1) + grady))));
XPutPixel(buffer_map, (across<<1)+1,(down<<1),
- bright(dx, XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady)));
+ bright(dx, grayscale(XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady))));
XPutPixel(buffer_map, (across<<1), (down<<1)+1,
- bright(dx, XGetPixel(orig_map, (across<<1) + gradx,
(down<<1) + grady1)));
+ bright(dx, grayscale(XGetPixel(orig_map, (across<<1) +
gradx, (down<<1) + grady1))));
XPutPixel(buffer_map, (across<<1)+1,(down<<1)+1,
- bright(dx, XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady1)));
+ bright(dx, grayscale(XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady1))));
} else {
/* Could use XCopyArea, but XPutPixel is faster */
XPutPixel(buffer_map, (across<<1), (down<<1),
- XGetPixel(orig_map, (across<<1) + gradx, (down<<1) +
grady));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx,
(down<<1) + grady)));
XPutPixel(buffer_map, (across<<1)+1,(down<<1),
- XGetPixel(orig_map, (across<<1) + gradx1,(down<<1) +
grady));
+ grayscale(XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady)));
XPutPixel(buffer_map, (across<<1), (down<<1)+1,
- XGetPixel(orig_map, (across<<1) + gradx, (down<<1) +
grady1));
+ grayscale(XGetPixel(orig_map, (across<<1) + gradx,
(down<<1) + grady1)));
XPutPixel(buffer_map, (across<<1)+1,(down<<1)+1,
- XGetPixel(orig_map, (across<<1) + gradx1,(down<<1) +
grady1));
+ grayscale(XGetPixel(orig_map, (across<<1) +
gradx1,(down<<1) + grady1)));
}
}
}
@@ -757,9 +802,20 @@
add_drop(ripple_blob, splash);
if (transparent) {
+ if (grayscale_p)
+ {
+ int across, down;
+ for (down = 0; down < bigheight; down++)
+ for (across = 0; across < bigwidth; across++)
+ XPutPixel(buffer_map, across, down,
+ grayscale(XGetPixel(orig_map, across, down)));
+ }
+ else
+ {
/* There's got to be a better way of doing this XCopyArea? */
memcpy(buffer_map->data, orig_map->data,
bigheight * buffer_map->bytes_per_line);
+ }
} else {
int across, down, color;
@@ -892,6 +948,7 @@
"*stir: False",
"*fluidity: 6",
"*light: 0",
+ "*grayscale: False",
#ifdef HAVE_XSHM_EXTENSION
"*useSHM: True",
#endif /* HAVE_XSHM_EXTENSION */
@@ -910,6 +967,7 @@
{"-stir", ".stir", XrmoptionNoArg, "True"},
{"-fluidity", ".fluidity", XrmoptionSepArg, 0},
{"-light", ".light", XrmoptionSepArg, 0},
+ {"-grayscale", ".grayscale", XrmoptionNoArg, "True"},
#ifdef HAVE_XSHM_EXTENSION
{"-shm", ".useSHM", XrmoptionNoArg, "True"},
{"-no-shm", ".useSHM", XrmoptionNoArg, "False"},
@@ -928,6 +986,7 @@
int stir = get_boolean_resource("stir", "Boolean");
int fluidity = get_integer_resource("fluidity", "Integer");
transparent = get_boolean_resource("water", "Boolean");
+ grayscale_p = get_boolean_resource("grayscale", "Boolean");
#ifdef HAVE_XSHM_EXTENSION
use_shm = get_boolean_resource("useSHM", "Boolean");
#endif /* HAVE_XSHM_EXTENSION */
@@ -964,9 +1023,16 @@
maxbits = MIN(MIN(BITCOUNT(rmask), BITCOUNT(gmask)), BITCOUNT(bmask));
light -= 8-maxbits;
if (light < 0) light = 0;
- } else
+ } else {
+ if (grayscale_p)
+ {
+ set_mask(visual->red_mask, &rmask, &rshift);
+ set_mask(visual->green_mask, &gmask, &gshift);
+ set_mask(visual->blue_mask, &bmask, &bshift);
+ }
draw_transparent = draw_transparent_vanilla;
-
+ }
+
init_ripples(0, -SPLASH); /* Start off without any drops */
/* Main drawing loop */
only in patch2:
unchanged:
--- xscreensaver-4.21-unmodified/hacks/ripples.man 2002-05-31
12:05:47.000000000 +0900
+++ xscreensaver-4.21/hacks/ripples.man 2005-09-28 18:07:52.000000000 +0900
@@ -14,6 +14,7 @@
[\-water]
[\-stir]
[\-oily]
+[\-grayscale]
[\-colors \fInumber\fP]
[\-no-shm]
.SH DESCRIPTION
@@ -53,6 +54,10 @@
.B \-oily | \-no-oily
Psychedelic Colors. Boolean.
.TP 8
+.B \-grayscale
+Convert the screen image to grayscale.
+Ignored if we don't grab the screen image.
+.TP 8
.B \-colors \fInumber\fP
Colors Two. Default: 200.
.TP 8