Convert Xamarin.Forms.Color to RGB

Hi there,

I have created a Page with RGB sliders for a custom app theming. Now I wanted to set the values of the sliders to the color which is the user about to change, so you can create a new theme from the base of the old one. This works relatively good, but I have problems with the Xamarin.Forms.color , when I have a colour like Dark green light pink the value of the sliders does not represent the color... Does anybody has an idea how I can convert those colors to RGB?

Cheers for your help
Martin Muenster

Best Answers

  • Accepted Answer

    Actually that is what I am already doing, I get the R, G and B value from the color in the same way as in the example, but than don't convert it into a hex but use the values directly for the sliders. The only difference is that I don't get the Alpha value, but I think that the Alpha value is not abel to change a color that hard.
    But I know found my mistake, the reason for the strange color was that I had instead of *255 *2255 for the Blue Value, because I do the multiplication directly before I give the value to the slider, so I couldn't see the mistake when I was looking at the values, I can not belief that I searched for such a long time for a solution and didn't see this typing error :)
    Thanks for your support, in the moment when I was preparing the code for posting here I saw the mitake o:)

Answers

  • I had a further look at the structure of the format of the xamarin.forms.color, I converted it to a string and noticed that it contains values for red, green, blue, Gue, Saturation ans Luminosity. I thought that rgb and h,s,l are complete differnet things and can't be combined, but obviously(at least for me) is this the case. I haven't find anything in the internet about this format of color and have no idea how I can convert this into only rgb... Anybody an idea?

  • MartinMuensterMartinMuenster Member ✭✭
    Accepted Answer

    Actually that is what I am already doing, I get the R, G and B value from the color in the same way as in the example, but than don't convert it into a hex but use the values directly for the sliders. The only difference is that I don't get the Alpha value, but I think that the Alpha value is not abel to change a color that hard.
    But I know found my mistake, the reason for the strange color was that I had instead of *255 *2255 for the Blue Value, because I do the multiplication directly before I give the value to the slider, so I couldn't see the mistake when I was looking at the values, I can not belief that I searched for such a long time for a solution and didn't see this typing error :)
    Thanks for your support, in the moment when I was preparing the code for posting here I saw the mitake o:)

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

    Excellent! The act of asking a question often leads to the solution... ;)

Sign In or Register to comment.