summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2002-05-31 00:02:54 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-05-31 00:02:54 +0000
commit3a745537f04abf6a78224260dda7b13f6c35d55c (patch)
tree95329d8b348949ab0b9e98b3742f6cd8d7853cec /src/tools
parent3d62f360fe620b52d8d2c3909c43894335d118af (diff)
downloadmetacity-3a745537f04abf6a78224260dda7b13f6c35d55c.tar.gz
metacity-3a745537f04abf6a78224260dda7b13f6c35d55c.tar.bz2
verbose-log on startup whether we were compiled with various extensions
2002-05-30 Havoc Pennington <hp@redhat.com> * src/main.c (main): verbose-log on startup whether we were compiled with various extensions * src/display.c (meta_display_queue_retheme_all_windows): reapply shape mask when changing themes, sucks to do it here though, makes theme changing slower. Needs fixing. * src/theme-parser.c (parse_toplevel_element): parse rounded corner options to frame_geometry * src/frames.c (meta_frames_apply_shapes): apply rounded corners if requested by the theme * configure.in (HAVE_SHAPE): check for shape extension
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/Makefile.am10
-rw-r--r--src/tools/metacity-grayscale.c109
2 files changed, 116 insertions, 3 deletions
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 5e9af94..9973db8 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -15,9 +15,12 @@ metacity_message_SOURCES= \
metacity_window_demo_SOURCES= \
metacity-window-demo.c
-metacity_mag_SOURCES= \
+metacity_mag_SOURCES= \
metacity-mag.c
+metacity_grayscale_SOURCES= \
+ metacity-grayscale.c
+
metacity_properties_SOURCES= \
metacity-properties.c
@@ -35,13 +38,14 @@ desktop_DATA=$(Desktop_in_files:.desktop.in=.desktop)
bin_PROGRAMS=metacity-message metacity-window-demo metacity-properties
-## cheesy hack I use, doesn't really have any business existing. ;-)
-noinst_PROGRAMS=metacity-mag
+## cheesy hacks I use, don't really have any business existing. ;-)
+noinst_PROGRAMS=metacity-mag metacity-grayscale
metacity_message_LDADD= @METACITY_MESSAGE_LIBS@
metacity_window_demo_LDADD= @METACITY_WINDOW_DEMO_LIBS@
metacity_properties_LDADD= @METACITY_PROPS_LIBS@
metacity_mag_LDADD= @METACITY_WINDOW_DEMO_LIBS@
+metacity_grayscale_LDADD = @METACITY_WINDOW_DEMO_LIBS@
EXTRA_DIST=$(icon_DATA) $(ui_DATA) $(propicon_DATA) $(Desktop_in_files)
diff --git a/src/tools/metacity-grayscale.c b/src/tools/metacity-grayscale.c
new file mode 100644
index 0000000..8d0cd68
--- /dev/null
+++ b/src/tools/metacity-grayscale.c
@@ -0,0 +1,109 @@
+/* Hack for grayscaling an image */
+
+/*
+ * Copyright (C) 2002 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
+
+static GdkPixbuf*
+grayscale_pixbuf (GdkPixbuf *pixbuf)
+{
+ GdkPixbuf *gray;
+ guchar *pixels;
+ int rowstride;
+ int pixstride;
+ int row;
+ int n_rows;
+ int width;
+
+ gray = gdk_pixbuf_copy (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (gray);
+ pixstride = gdk_pixbuf_get_has_alpha (gray) ? 4 : 3;
+
+ pixels = gdk_pixbuf_get_pixels (gray);
+ n_rows = gdk_pixbuf_get_height (gray);
+ width = gdk_pixbuf_get_width (gray);
+
+ row = 0;
+ while (row < n_rows)
+ {
+ guchar *p = pixels + row * rowstride;
+ guchar *end = p + (pixstride * width);
+
+ while (p != end)
+ {
+ double v = INTENSITY (p[0], p[1], p[2]);
+
+ p[0] = (guchar) v;
+ p[1] = (guchar) v;
+ p[2] = (guchar) v;
+
+ p += pixstride;
+ }
+
+ ++row;
+ }
+
+ return gray;
+}
+
+int
+main (int argc, char **argv)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *gray;
+ GError *err;
+
+ if (argc != 2)
+ {
+ g_printerr ("specify a single image on the command line\n");
+ return 1;
+ }
+
+ g_type_init ();
+
+ err = NULL;
+ pixbuf = gdk_pixbuf_new_from_file (argv[1], &err);
+ if (err != NULL)
+ {
+ g_printerr ("failed to load image: %s\n", err->message);
+ g_error_free (err);
+ return 1;
+ }
+
+ gray = grayscale_pixbuf (pixbuf);
+
+ err = NULL;
+ gdk_pixbuf_save (gray, "grayscale.png", "png", &err, NULL);
+ if (err != NULL)
+ {
+ g_printerr ("failed to save image: %s\n", err->message);
+ g_error_free (err);
+ return 1;
+ }
+
+ g_print ("wrote grayscale.png\n");
+
+ return 0;
+}