LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-11-2012, 05:57 AM   #1
anurag4u
LQ Newbie
 
Registered: Nov 2009
Location: India
Posts: 20

Rep: Reputation: 0
Post RGB values for grayscale in 24-bit


Hi,
Please see the code below.

Code:
for (i=0; i<= 255; i++)
  {
    sprintf(spec, "rgb:%02x/%02x/%02x", i, i, i);

    if(XParseColor(display, default_cmap, spec, &color))
    {
        XAllocColor(display, default_cmap, &color);
    }
}
then I am printing color.red, color.blue and color.green values. These values range from 0 to 65535.


If I understand it correctly, Each color (R, G, B) has 8-bits each, so values should range from 0 to 255.


Please help me understand why the values are 256 times the expected values.
 
Old 12-11-2012, 08:30 AM   #2
steelneck
Member
 
Registered: Nov 2005
Distribution: Slackware, Arch
Posts: 43

Rep: Reputation: 8
Because you have an RGB image, not a single channel BW. An RGB image in 24-bit will have a range of 0 to 65535 for each channel, and if that image look BW, it is only desaturated.
 
1 members found this post helpful.
Old 12-12-2012, 11:12 PM   #3
anurag4u
LQ Newbie
 
Registered: Nov 2009
Location: India
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks for the explanation.
 
  


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
initializiation code for 8-bit serial RGB interface display? sunr2007 Linux - Embedded & Single-board computer 1 08-03-2009 10:04 AM
Can I change the ANSI RGB values for CLI mudflap Slackware 6 10-13-2008 08:48 PM
Fastest way to draw a 16 or 32 bit RGB bitmap in XLIB (without GL)? fcdev Programming 1 11-14-2007 03:18 AM
.png to grayscale command bendeco13 Linux - General 2 03-18-2005 03:56 PM
Grayscale mode in X with depth 16 bacon22 Linux - General 2 04-17-2004 11:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:25 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