Questions tagged [rgb]

RGB stands for Red-Green-Blue and specifies a color using three values, which represent the respective amount of red, green, and blue in the color. RGB is the basis for the color model used by most color display devices nowadays.

The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. RGB is a color notation used in most computing devices nowadays.

RGB colors are represented by a tuple of three values (one per primary color), which are typically either bytes ranging from 0 to 255 or floating-point values ranging from 0.0 to 1.0.

3547 questions
66
votes
11 answers

Fast method to copy memory with translation - ARGB to BGR

Overview I have an image buffer that I need to convert to another format. The origin image buffer is four channels, 8 bits per channel, Alpha, Red, Green, and Blue. The destination buffer is three channels, 8 bits per channel, Blue, Green, and…
Adam Davis
  • 91,931
  • 60
  • 264
  • 330
65
votes
15 answers

Javascript color gradient

Using javascript with or without Jquery, I need to a create a gradient of colours based on a start and finish color. Is this possible to do programmatically? The end colour is only ever going to be darker shade of the start colour and it's for an…
Dave
  • 651
  • 1
  • 5
  • 3
62
votes
7 answers

How to get the RGB Code (INT) from an UIColor in Swift

I would like to get the RGB Value of an UIColor in Swift: let swiftColor = UIColor(red: 1, green: 165/255, blue: 0, alpha: 1) println("RGB Value is:"); println(swiftColor.getRGB()); <<<<<< How to do that ? In Java I would do it as follows: Color…
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
59
votes
10 answers

How do I get red green blue (RGB) and alpha back from a UIColor object?

I am getting a UIColor returned from this method: - (UIColor *)getUserSelectedColor { return [UIColor colorWithRed:redSlider.value green:greenSlider.value blue:blueSlider.value alpha:1.0]; } and getting color like this: UIColor…
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
57
votes
8 answers

How to pick color palette for a pie-chart?

I have some code that generates image of a pie chart. It's a general purpose class, so any number of slices can be given as input. Now I have problem picking good colors for the slices. Is there some algorithm that is good at that? Colors need to…
codeguru
  • 1,851
  • 2
  • 15
  • 11
54
votes
5 answers

rgb values to 0 to 1 scale

I'm trying to calculate some RGB colors (0 - 255) for a 0 to 1 scale. Does anyone knows a online converter or it exists a math formula? Lets say that I want to convert 125 RGB with (0 to 255 scale) to a 0 to 1 scale.
el.severo
  • 2,202
  • 6
  • 31
  • 62
53
votes
10 answers

Converting hex color to RGB and vice-versa

What is the most efficient way to do this?
moo
  • 7,619
  • 9
  • 42
  • 40
53
votes
8 answers

Hex colors: Numeric representation for "transparent"?

I am building a web CMS in which the user can choose colours for certain site elements. I would like to convert all colour values to hex to avoid any further formatting hassle ("rgb(x,y,z)" or named colours). I have found a good JS library for…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
52
votes
6 answers

Javascript convert HSB/HSV color to RGB accurately

I need to accurately convert HSB to RGB but I am not sure how to get around the problem of turning decimals into whole numbers without rounding. This is the current function I have out of a colorpicker library: HSBToRGB = function (hsb) { var…
that_guy
  • 2,313
  • 4
  • 33
  • 46
50
votes
9 answers

What is the best way to average two colors that define a linear gradient?

If I have two colors defined by their RGB values, can I average the Red, Green and Blue values and then combine to define a third color that looks like a visual average of the two? ie NewColor = (R1+R2)/2,(G1+G2)/2,(B1+B2)/2 EDIT1: Thanks for all…
eft
  • 2,509
  • 6
  • 26
  • 24
50
votes
16 answers

Generate random colors (RGB)

I just picked up image processing in python this past week at the suggestion of a friend to generate patterns of random colors. I found this piece of script online that generates a wide array of different colors across the RGB spectrum. def…
Travis A.
  • 513
  • 1
  • 5
  • 5
50
votes
5 answers

What are the RGB codes for the Conditional Formatting 'Styles' in Excel?

I've got some cells that I have Conditionally Formatted to Excel's standard 'Bad' Style (Dark red text, light red fill). In another column I have cells that I have created a Conditional Formatting formula for. I also want to code these to match the…
a76marine
  • 1,669
  • 2
  • 12
  • 7
50
votes
5 answers

Understanding BufferedImage.getRGB output values

I'm getting an integer value for the pixel in an image using this method: int colour = img.getRGB(x, y); Then I'm printing out the values and I see that black pixels correspond to a value like "-16777216", a kind of blue to something like…
leonardo
  • 537
  • 1
  • 4
  • 7
49
votes
5 answers

How do I create a UIColor from RGBA?

I want to use NSAttributedString in my project, but when I'm trying to set color, which isn't from the standard set (redColor, blackColor, greenColor etc.) UILabel displays these letters in white color. Here is my line of this…
agoncharov
  • 822
  • 1
  • 6
  • 15
48
votes
10 answers

HSV to RGB Color Conversion

Is there a way to convert HSV color arguments to RGB type color arguments using pygame modules in python? I tried the following code, but it returns ridiculous values. import colorsys test_color = colorsys.hsv_to_rgb(359, 100,…
AvZ
  • 997
  • 3
  • 14
  • 25