changeset 2731:304fbae3fd0f

Remote command --pixel-info Additional remote command: geeqie --remote --pixel-info Gives X, Y and RGB of the mouse pointer on the current image. Format is: [x,y]: RGB( r, g, b)
author Colin Clark <colin.clark@cclark.uk>
date Tue, 27 Feb 2018 17:12:33 +0000
parents 92c66393fce2
children cff064279094
files doc/docbook/GuideReferenceCommandLine.xml geeqie.1 src/remote.c web/help/GuideReferenceCommandLine.html
diffstat 4 files changed, 72 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/doc/docbook/GuideReferenceCommandLine.xml	Sun Feb 11 11:12:37 2018 +0000
+++ b/doc/docbook/GuideReferenceCommandLine.xml	Tue Feb 27 17:12:33 2018 +0000
@@ -223,6 +223,11 @@
           </row>
           <row>
             <entry />
+            <entry>--pixel-info</entry>
+            <entry>Print X, Y and RGB of mouse pointer on current image</entry>
+          </row>
+          <row>
+            <entry />
             <entry>view:&lt;file&gt;</entry>
             <entry>Open new window containing &lt;file&gt;</entry>
           </row>
--- a/geeqie.1	Sun Feb 11 11:12:37 2018 +0000
+++ b/geeqie.1	Tue Feb 27 17:12:33 2018 +0000
@@ -168,6 +168,10 @@
 Print filename of current image.
 .br
 .B
+.IP \-\-pixel\-info
+Print X, Y and RGB of mouse pointer on current image.
+.br
+.B
 .IP \-\-view:<FILE>
 Open FILE in new window.
 .br
--- a/src/remote.c	Sun Feb 11 11:12:37 2018 +0000
+++ b/src/remote.c	Tue Feb 27 17:12:33 2018 +0000
@@ -30,6 +30,7 @@
 #include "layout.h"
 #include "layout_image.h"
 #include "misc.h"
+#include "pixbuf-renderer.h"
 #include "slideshow.h"
 #include "ui_fileops.h"
 #include "rcfile.h"
@@ -608,6 +609,51 @@
 	gr_raise(text, channel, data);
 }
 
+static void gr_pixel_info(const gchar *text, GIOChannel *channel, gpointer data)
+{
+	gchar *pixel_info;
+	gint x_pixel, y_pixel;
+	gint width, height;
+	gint r_mouse, g_mouse, b_mouse;
+	PixbufRenderer *pr;
+	LayoutWindow *lw = NULL;
+
+	if (!layout_valid(&lw)) return;
+
+	pr = (PixbufRenderer*)lw->image->pr;
+
+	if (pr)
+		{
+		pixbuf_renderer_get_image_size(pr, &width, &height);
+		if (width < 1 || height < 1) return;
+
+		pixbuf_renderer_get_mouse_position(pr, &x_pixel, &y_pixel);
+
+		if (x_pixel >= 0 && y_pixel >= 0)
+			{
+			pixbuf_renderer_get_pixel_colors(pr, x_pixel, y_pixel,
+							 &r_mouse, &g_mouse, &b_mouse);
+
+			pixel_info = g_strdup_printf(_("[%d,%d]: RGB(%3d,%3d,%3d)"),
+						 x_pixel, y_pixel,
+						 r_mouse, g_mouse, b_mouse);
+
+			g_io_channel_write_chars(channel, pixel_info, -1, NULL, NULL);
+			g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
+
+			g_free(pixel_info);
+			}
+		else
+			{
+			return;
+			}
+		}
+	else
+		{
+		return;
+		}
+}
+
 static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data)
 {
 	LayoutWindow *lw = NULL; /* NULL to force layout_valid() to do some magic */
@@ -798,6 +844,7 @@
 	{ NULL, "file:",                gr_file_load,           TRUE,  FALSE, N_("<FILE>"), N_("open FILE, bring Geeqie window to the top") },
 	{ NULL, "File:",                gr_file_load_no_raise,  TRUE,  FALSE, N_("<FILE>"), N_("open FILE, do not bring Geeqie window to the top") },
 	{ NULL, "--tell",               gr_file_tell,           FALSE, FALSE, NULL, N_("print filename of current image") },
+	{ NULL, "--pixel-info",         gr_pixel_info,          FALSE, FALSE, NULL, N_("print pixel info of mouse pointer on current image") },
 	{ NULL, "view:",                gr_file_view,           TRUE,  FALSE, N_("<FILE>"), N_("open FILE in new window") },
 	{ NULL, "--list-clear",         gr_list_clear,          FALSE, FALSE, NULL, N_("clear command line collection list") },
 	{ NULL, "--list-add:",          gr_list_add,            TRUE,  FALSE, N_("<FILE>"), N_("add FILE to command line collection list") },
--- a/web/help/GuideReferenceCommandLine.html	Sun Feb 11 11:12:37 2018 +0000
+++ b/web/help/GuideReferenceCommandLine.html	Tue Feb 27 17:12:33 2018 +0000
@@ -675,50 +675,55 @@
 </tr>
 <tr class="tr-shade">
 <td class="td-colsep td-rowsep"></td>
+<td class="td-colsep td-rowsep">--pixel-info</td>
+<td class="td-rowsep">Print X, Y and RGB of mouse pointer on current image</td>
+</tr>
+<tr>
+<td class="td-colsep td-rowsep"></td>
 <td class="td-colsep td-rowsep">view:&lt;file&gt;</td>
 <td class="td-rowsep">Open new window containing &lt;file&gt;</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep td-rowsep"></td>
 <td class="td-colsep td-rowsep">--list-clear</td>
 <td class="td-rowsep">Clear command line collection list</td>
 </tr>
-<tr class="tr-shade">
+<tr>
 <td class="td-colsep td-rowsep"></td>
 <td class="td-colsep td-rowsep">--list-add:&lt;file&gt;</td>
 <td class="td-rowsep">Add &lt;file&gt; to command line collection list</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep td-rowsep"></td>
 <td class="td-colsep td-rowsep">raise</td>
 <td class="td-rowsep">Bring the geeqie window to the top</td>
 </tr>
-<tr class="tr-shade">
+<tr>
 <td class="td-colsep td-rowsep">-ct:clear|clean</td>
 <td class="td-colsep td-rowsep">--cache-thumbs:clear|clean</td>
 <td class="td-rowsep">clear or clean thumbnail cache</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep td-rowsep">-cs:clear|clean</td>
 <td class="td-colsep td-rowsep">--cache-shared:clear|clean</td>
 <td class="td-rowsep">clear or clean shared thumbnail cache</td>
 </tr>
-<tr class="tr-shade">
+<tr>
 <td class="td-colsep td-rowsep">-cm</td>
 <td class="td-colsep td-rowsep">--cache-metadata</td>
 <td class="td-rowsep">clean the metadata cache</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep td-rowsep">-cr:&lt;folder&gt;</td>
 <td class="td-colsep td-rowsep">--cache-render:&lt;folder&gt;</td>
 <td class="td-rowsep">render thumbnails</td>
 </tr>
-<tr class="tr-shade">
+<tr>
 <td class="td-colsep td-rowsep">-crr:&lt;folder&gt;</td>
 <td class="td-colsep td-rowsep">--cache-render-recurse:&lt;folder&gt;</td>
 <td class="td-rowsep">render thumbnails recursively</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep td-rowsep">-crs:&lt;folder&gt;</td>
 <td class="td-colsep td-rowsep">--cache-render-shared:&lt;folder&gt;</td>
 <td class="td-rowsep">
@@ -726,12 +731,12 @@
               <a name="-noteref-ref2"></a><sup><a class="footnote" href="#ref2">2</a></sup>
             </td>
 </tr>
-<tr class="tr-shade">
+<tr>
 <td class="td-colsep td-rowsep">-crsr:&lt;folder&gt;</td>
 <td class="td-colsep td-rowsep">--cache-render-shared-recurse:&lt;folder&gt;</td>
 <td class="td-rowsep">render thumbnails recursively</td>
 </tr>
-<tr>
+<tr class="tr-shade">
 <td class="td-colsep"></td>
 <td class="td-colsep">--lua:&lt;file&gt;,&lt;lua script&gt;</td>
 <td>run lua script on file</td>