473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

RGB values

2
Dear All,
I want to know how to convert RGB values to a unique number in c#.
for an example in the television we can get one value as follows.
(alpha)R+(beeta)G+(gema)B
Oct 21 '08 #1
5 1264
r035198x
13,262 8TB
Can you give more details. I thought the RGB was for Red, Green and Blue colors. What are the RGB values in your case and how do they map to integers.
Oct 21 '08 #2
(alpha)R+(beeta)G+(gema)B. You can concatenate the number to have. every color has less than 256 tones in RBG so:

red*1000000+green*1000+blue = unique number. Imagine a color defined by:
red = 152
green = 12
blue = 250
then your unique number, if you follow this formula, will be:
152012250

public int RBGtoUnique(int red, int green, int blue)
{
return red*1000000+green*1000+blue;
}

use remainders for decompressing the number.
Oct 21 '08 #3
anoji
2
yes, R means red,G means green and B means blue.i can read RGB values of an image. but i want a single value for a picxel.
Oct 21 '08 #4
tlhintoq
3,525 Expert 2GB
yes, R means red,G means green and B means blue.i can read RGB values of an image. but i want a single value for a picxel.
MathewWavery gave you a pretty good plan.

Though I am personally curious... How do you plan on using this? I can't for the life of me think up a really good use for taking RGB values and making them a single number. You can't really be on a machine so hard up for RAM that you need one big int, instead of three shorts - can you?
Oct 21 '08 #5
Plater
7,872 Expert 4TB
Well the Color class takes RGB values and will give you a single integer value.

Seems sort of redundant to it:
Expand|Select|Wrap|Line Numbers
  1. int mycolor=Color.FromArgb(iRed,iGreen,iBlue).ToArgb();
  2.  
Oct 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
1
by: Sue Adams | last post by:
I have a form on an asp page and am trying to write the code to place the values of all checkboxes that have been selected, into an array. The checkbox values will be used in a dynamic sql statement...
5
by: James Baker | last post by:
I have a form that has a dropdown list that will cause a post to the same page when it's changed. The problem I'm running into is that all of the controls reset to their default values (obviously...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
4
by: Steve Hall | last post by:
Folks, My secnario involves two tables - ObservationRegister, and Person. ObservationRegister contains most of the "useful" fields, including the UserID of the person that raised the record, and...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
2
by: Hennie | last post by:
I apologise if this is a stupid question, but I would appreciated any help on this subject. I want to create a view (VIEW_1 in example below) where I take numeric values from a field in one...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
13
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! With VALUES you can do something like: SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER) which will give you: LETTER NUMBER ------ ------ A 1 B 2...
8
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.