LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-17-2013, 05:21 AM   #1
waddles
Member
 
Registered: Sep 2012
Posts: 372

Rep: Reputation: 1
Extracting color of a pixel with Slackware


I have a need to extract the color of a screen pixel usibg shell script. I have found programs/commands like xdotool, grabc, that are supposed to do that but these are not in the full install of Slackware. I keep running into these when I search the web so they must be a sort of default.
I finally found a "mouse" command (v.13.37) that described several protocols but none for my Logitech trackball. This command apparently can get bits back and these could be converted to x,y coordinates for the mouse from their dx and dy bits.
Has anyone used the "mouse" command to extract the coordinates of the mouse? Does anyone know a way to find the color of a screen pixel given the coordinates in Slackware?
If not I may have to create a file of the screen with xwd then use cursor positioning.

Last edited by waddles; 10-17-2013 at 05:23 AM.
 
Old 10-17-2013, 05:42 AM   #2
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Are you trying to find the pixel colour from the screen in X or from a console screen?

There are so many different ways to return the value but you need to give a starting point as different graphics modes have different routines.
 
Old 10-17-2013, 03:07 PM   #3
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
Do you use a compositor? (Transparent windows, etc.) If you don't, this is easy.
Code:
import -window root -crop 1x1+100+200 foo.txt
Here you put in coordinates for 100 and 200. This gives you something like
Code:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (15420,15420,15420)  #3C3C3C3C3C3C  srgb(60,60,60)
which you can awk into submission.

If you DO use a compositor, neither import nor xwd can see the transparency
(here they fill it with black), so you may have to use a different program.
GIMP works, but I don't know the batch mode curse to take a screenshot.
scrot may also work, but it doesn't come with Slackware.

Last edited by qweasd; 10-17-2013 at 07:41 PM.
 
1 members found this post helpful.
Old 10-18-2013, 01:49 AM   #4
waddles
Member
 
Registered: Sep 2012
Posts: 372

Original Poster
Rep: Reputation: 1
@wildwizard: by console mode I presume U are defining it as the console mode as the system monitor as presented by the XFCE menu or do U mean as like U get on boot up? Actually I need to cover all bases so yes to console mode and to x screen.

@qweasd: I must not be referring to a compositor as I have no idea what that is. As for transparency I have a difficult time understanding what is meant. GIMP's transparency concept, for example, seems to work in reverse of of what I expect it should.
What I am looking for is an X-windows like command where I put in pixel position measured from the top left corner in x,y (maybe like XGetPointerMapping or XChangePointerControl) and be at a location where in the same command or another I could then extract that pixel's color (maybe with XQueryColor). I just now looked at those Xcommands in "XWindowSystem" so they are probably not what I am after in bash/bournesh, but maybe they give a sense of what I am after.

Last edited by waddles; 10-18-2013 at 04:19 PM.
 
Old 10-18-2013, 01:41 PM   #5
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
This tells me you probably don't have a compositor (what window manager do you use?). So this will probably work:
Code:
$ function pixel_color () { import -window root -crop 1x1+$1+$2 -depth 8 txt:- | grep '^0' | sed 's/.*\(\#......\).*/\1/' ; }
$ pixel_color 10 10
#295682
 
Old 10-18-2013, 04:12 PM   #6
waddles
Member
 
Registered: Sep 2012
Posts: 372

Original Poster
Rep: Reputation: 1
I am using XFCE tho I have access to several other window managers.
I will try that and see how it goes.
I tried it with position 20 20 and get: #5E98E3
Am I correct in thinking this is: red=5E green=98 blue=E3? Why do I get a double beep?
I need to investigate tput as I just ran into its "initc" which may also do this (me tput stupid).

Last edited by waddles; 10-18-2013 at 05:39 PM.
 
Old 10-18-2013, 11:22 PM   #7
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
xfce comes with a compositor. If you have "effects" enabled, import will likely lie when you query blended and semi-transparent things. If you don't, it should do just fine.

Last edited by qweasd; 10-18-2013 at 11:25 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK/GDK 1.2 GdkPixmap: Set a pixel with a color TTL_2 Programming 2 01-14-2013 01:48 AM
Does pixel color identification software exist? KenJackson Linux - Software 7 12-31-2010 08:36 AM
Is there the color-theme.el slackware package? sycamorex Slackware 1 04-19-2009 08:16 PM
GIMP - 16 bit/color (48 bit/pixel) Maxxum9 Linux - Software 1 01-03-2005 08:43 PM
can slackware do 32 bit color depth alkad_mzu Slackware 6 11-16-2003 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration