locked
Convert Xamarin.Forms.Color to RGB RRS feed

  • Question

  • User374266 posted

    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

    Thursday, October 18, 2018 11:47 PM

Answers

  • User350 posted

    You may have already seen and discounted it, but does this stackoverflow post help? Or am I misunderstanding your problem?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 19, 2018 8:15 AM
  • User374266 posted

    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:)

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 19, 2018 8:57 AM

All replies

  • User374266 posted

    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?

    Friday, October 19, 2018 7:07 AM
  • User350 posted

    You may have already seen and discounted it, but does this stackoverflow post help? Or am I misunderstanding your problem?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 19, 2018 8:15 AM
  • User374266 posted

    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:)

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 19, 2018 8:57 AM
  • User350 posted

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

    Friday, October 19, 2018 9:16 AM