locked
Making Drawing.Color by seting RGB values RRS feed

  • Question

  • Hello,

    I'd like to know how to configure new System.Drawing.Color by seting RGB values. I need to make color from 3 ASCII converted chars. Following:

    sam = 115, 97, 109 to clolor is

    color.r=115

    color.g=97

    color.b=109

    then I can set to the bitmap pixel with color made that way

     

    Now the only problem is, that r,g,b parameters are only readable :/. Is there any way to SET values of color.r, g & b ??

    Saturday, September 23, 2006 3:04 PM

Answers

  • Color.FromArgb method is very useful in this kind of situation.
    And I think that this works in the way you want it to.. :)

    Dim myColor As Color = Color.FromArgb(r, g, b)

    Regards,
    Timo
    Saturday, September 23, 2006 3:28 PM

All replies

  •  

    Look at the FromArgb method.

    It has exactly what you want.

    Saturday, September 23, 2006 3:23 PM
  • Color.FromArgb method is very useful in this kind of situation.
    And I think that this works in the way you want it to.. :)

    Dim myColor As Color = Color.FromArgb(r, g, b)

    Regards,
    Timo
    Saturday, September 23, 2006 3:28 PM
  • txttext.Text = System.Drawing.Color.Black.ToArgb     equals    -16777216

    what can can i do with value like that ? and how can i make argb from 3 ascii strings

    Could u please give me a little example of making color from 3 numbers using fromargb please ?

    Saturday, September 23, 2006 3:31 PM
  • Thank u guys very much
    Saturday, September 23, 2006 3:33 PM
  • Oh - i have one more question - how to reverse that operaction to get 3 numbers from color :)

    Cause like i said before

    txttext.Text = System.Drawing.Color.Black.ToArgb     equals    -16777216

    Saturday, September 23, 2006 3:55 PM
  • You should try to get R, G and B values in a different way.
    All colors have those values so you can get them by doing this:

    txttext.Text = System.Drawing.Color.Black.R

    In the same whay you can get G, B values. Instead of R there must be G or B. There's also A which means Alpha, but it's not important in this situation. :) But fromArgb doesn't work this time. By the way that Argb means alpha, red, green, blue. Properties of a color. :)

    Timo
    Saturday, September 23, 2006 4:05 PM
  •  

    Everyone here is not a guy.

    Saturday, September 23, 2006 4:14 PM
  • Im sorry ReneeC  forgive
    Saturday, September 23, 2006 4:17 PM
  • Remember to mark best replies as answers.. :)
    Saturday, September 23, 2006 4:21 PM
  • Of course i do :P
    Saturday, September 23, 2006 4:28 PM
  •  

    Addix,

    Were all of your questions answered?

    Saturday, September 23, 2006 4:34 PM
  • Yes :) (so far ^^)
    Saturday, September 23, 2006 4:48 PM