[gnome-screenshot] screenshot: add vintage filter



commit 3b6f0b250e70bf1514145811c30e256cd3f64e55
Author: Nils Dagsson Moskopp <nils dieweltistgarnichtso net>
Date:   Sat Aug 10 19:14:58 2013 +0200

    screenshot: add vintage filter
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705847

 src/gnome-screenshot.1              |    6 +++-
 src/screenshot-application.c        |    5 +++-
 src/screenshot-interactive-dialog.c |   10 +++++-
 src/screenshot-shadow.c             |   49 +++++++++++++++++++++++++++++++++++
 src/screenshot-shadow.h             |    1 +
 5 files changed, 66 insertions(+), 5 deletions(-)
---
diff --git a/src/gnome-screenshot.1 b/src/gnome-screenshot.1
index d07e853..ad82dd0 100644
--- a/src/gnome-screenshot.1
+++ b/src/gnome-screenshot.1
@@ -1,4 +1,4 @@
-.TH "GNOME-SCREENSHOT" "1" "May 14, 2013" "" ""
+.TH "GNOME-SCREENSHOT" "1" "August 10, 2013" "" ""
 .SH NAME
 gnome-screenshot \- capture the screen, a window, or an user-defined area and save the snapshot image to a 
file.
 .SH SYNOPSIS
@@ -37,7 +37,9 @@ Take the screenshot after the specified delay [in seconds].
 Add an effect to the outside of the screenshot border.
 \fIEFFECT\fR can be ``shadow'' 
 (adding drop shadow), ``border'' (adding rectangular
-space around the screenshot) or ``none'' (no effect).
+space around the screenshot), ``vintage'' (desaturating
+the screenshot slightly, tinting it and adding
+rectangular space around it) or ``none'' (no effect).
 Default is ``none''.
 .TP
 \fB-i, --interactive\fR
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index d2c622b..8f73d5f 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -526,6 +526,9 @@ finish_prepare_screenshot (ScreenshotApplication *self,
         case 'b': /* border */
           screenshot_add_border (&screenshot);
           break;
+        case 'v': /* vintage */
+          screenshot_add_vintage (&screenshot);
+          break;
         case 'n': /* none */
         default:
           break;
@@ -646,7 +649,7 @@ screenshot_application_local_command_line (GApplication *app,
     { "remove-border", 'B', 0, G_OPTION_ARG_NONE, &disable_border_arg, N_("Remove the window border from the 
screenshot"), NULL },
     { "include-pointer", 'p', 0, G_OPTION_ARG_NONE, &include_pointer_arg, N_("Include the pointer with the 
screenshot"), NULL },
     { "delay", 'd', 0, G_OPTION_ARG_INT, &delay_arg, N_("Take screenshot after specified delay [in 
seconds]"), N_("seconds") },
-    { "border-effect", 'e', 0, G_OPTION_ARG_STRING, &border_effect_arg, N_("Effect to add to the border 
(shadow, border or none)"), N_("effect") },
+    { "border-effect", 'e', 0, G_OPTION_ARG_STRING, &border_effect_arg, N_("Effect to add to the border 
(shadow, border, vintage or none)"), N_("effect") },
     { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive_arg, N_("Interactively set options"), NULL },
     { "file", 'f', 0, G_OPTION_ARG_FILENAME, &file_arg, N_("Save screenshot directly to this file"), 
N_("filename") },
     { "version", 0, 0, G_OPTION_ARG_NONE, &version_arg, N_("Print version information and exit"), NULL },
diff --git a/src/screenshot-interactive-dialog.c b/src/screenshot-interactive-dialog.c
index 5197dea..a2eb599 100644
--- a/src/screenshot-interactive-dialog.c
+++ b/src/screenshot-interactive-dialog.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2001 Jonathan Blandford <jrb alum mit edu>
  * Copyright (C) 2006 Emmanuele Bassi <ebassi gnome org>
  * Copyright (C) 2008, 2011 Cosimo Cecchi <cosimoc gnome org>
+ * Copyright (C) 2013 Nils Dagsson Moskopp <nils dieweltistgarnichtso net>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -47,7 +48,8 @@ enum
 typedef enum {
   SCREENSHOT_EFFECT_NONE,
   SCREENSHOT_EFFECT_SHADOW,
-  SCREENSHOT_EFFECT_BORDER
+  SCREENSHOT_EFFECT_BORDER,
+  SCREENSHOT_EFFECT_VINTAGE
 } ScreenshotEffectType;
 
 #define TARGET_TOGGLE_DESKTOP 0
@@ -153,7 +155,8 @@ typedef struct {
 static const ScreenshotEffect effects[] = {
   { SCREENSHOT_EFFECT_NONE, N_("None"), "none" },
   { SCREENSHOT_EFFECT_SHADOW, N_("Drop shadow"), "shadow" },
-  { SCREENSHOT_EFFECT_BORDER, N_("Border"), "border" }
+  { SCREENSHOT_EFFECT_BORDER, N_("Border"), "border" },
+  { SCREENSHOT_EFFECT_VINTAGE, N_("Vintage"), "vintage" }
 };
 
 static guint n_effects = G_N_ELEMENTS (effects);
@@ -198,6 +201,9 @@ create_effects_combo (void)
       gtk_combo_box_set_active (GTK_COMBO_BOX (retval),
                                 SCREENSHOT_EFFECT_BORDER);
       break;
+    case 'v': /* vintage */
+      gtk_combo_box_set_active (GTK_COMBO_BOX (retval),
+                                SCREENSHOT_EFFECT_VINTAGE);
     case 'n': /* none */
       gtk_combo_box_set_active (GTK_COMBO_BOX (retval),
                                 SCREENSHOT_EFFECT_NONE);
diff --git a/src/screenshot-shadow.c b/src/screenshot-shadow.c
index abb0a48..194ba31 100644
--- a/src/screenshot-shadow.c
+++ b/src/screenshot-shadow.c
@@ -1,6 +1,7 @@
 /* screenshot-shadow.c - part of GNOME Screenshot
  *
  * Copyright (C) 2001-2006  Jonathan Blandford <jrb alum mit edu>
+ * Copyright (C) 2013  Nils Dagsson Moskopp <nils dieweltistgarnichtso net>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -34,6 +35,12 @@
 #define OUTLINE_OFFSET  0
 #define OUTLINE_OPACITY 1.0
 
+#define VINTAGE_SATURATION 0.8
+#define VINTAGE_OVERLAY_COLOR 0xFFFBF2A3
+#define VINTAGE_SOURCE_ALPHA 192
+#define VINTAGE_OUTLINE_COLOR 0xFFEEEEEE
+#define VINTAGE_OUTLINE_RADIUS 24
+
 #define dist(x0, y0, x1, y1) sqrt(((x0) - (x1))*((x0) - (x1)) + ((y0) - (y1))*((y0) - (y1)))
 
 typedef struct {
@@ -233,3 +240,45 @@ screenshot_add_border (GdkPixbuf **src)
   g_object_unref (*src);
   *src = dest;
 }
+
+void
+screenshot_add_vintage (GdkPixbuf **src)
+{
+  GdkPixbuf *dest;
+  static ConvFilter *filter = NULL;
+  
+  if (!filter)
+    filter = create_outline_filter (VINTAGE_OUTLINE_RADIUS);
+  
+  dest = create_effect (*src, filter, 
+                       VINTAGE_OUTLINE_RADIUS,
+                        OUTLINE_OFFSET, OUTLINE_OPACITY);
+
+  if (dest == NULL)
+         return;
+
+  gdk_pixbuf_fill(dest, VINTAGE_OUTLINE_COLOR);
+  gdk_pixbuf_composite (*src, dest,
+                       VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS,
+                       gdk_pixbuf_get_width (*src),
+                       gdk_pixbuf_get_height (*src),
+                       VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS, 1.0, 1.0,
+                       GDK_INTERP_HYPER, 255);
+  g_object_unref (*src);
+  *src = dest;
+
+  gdk_pixbuf_saturate_and_pixelate(*src, *src,
+    VINTAGE_SATURATION, FALSE);
+  dest = gdk_pixbuf_composite_color_simple(*src,
+                       gdk_pixbuf_get_width(*src),
+                       gdk_pixbuf_get_height(*src),
+                       GDK_INTERP_BILINEAR,
+                       VINTAGE_SOURCE_ALPHA, 64,
+                       VINTAGE_OVERLAY_COLOR, VINTAGE_OVERLAY_COLOR);
+
+  if (dest == NULL)
+         return;
+
+  g_object_unref (*src);
+  *src = dest;
+}
diff --git a/src/screenshot-shadow.h b/src/screenshot-shadow.h
index cac37db..932e687 100644
--- a/src/screenshot-shadow.h
+++ b/src/screenshot-shadow.h
@@ -24,5 +24,6 @@
 
 void screenshot_add_shadow (GdkPixbuf **src);
 void screenshot_add_border (GdkPixbuf **src);
+void screenshot_add_vintage (GdkPixbuf **src);
 
 #endif /* __SCREENSHOT_SHADOW_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]