Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color Order In GetPalette #6

Open
ghost opened this issue Jun 28, 2017 · 7 comments
Open

Color Order In GetPalette #6

ghost opened this issue Jun 28, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Jun 28, 2017

only on Xamarin.forms nuget package:
//var pal = _colorThief.GetPalette(pictureBoxSpectrum.Image, 6, 10, false).ToList();
all the colors are correct, but Red and Blue color Bytes are swapped.
I was porting an app from windows forms app to Xamarin iOS, and noticed that all the colors are not the same, after some investigation turns out only instead of using RGB of your values, used them as BGR.

@KSemenenko
Copy link
Owner

Hi, thx for you issue!
It's only for iOS?

@ghost
Copy link
Author

ghost commented Jun 28, 2017 via email

@KSemenenko
Copy link
Owner

Hi @Houri93 please check it on version 1.0.0.4

@KSemenenko KSemenenko reopened this Jul 10, 2017
@ghost
Copy link
Author

ghost commented Jul 14, 2017

hello again, just updated to the latest version via nuget, the problem still exists as it has been previously

@KSemenenko
Copy link
Owner

@Houri93 Thank you. I will then continue to fix this.

@KSemenenko
Copy link
Owner

Hello! You could give me a picture and colors that should be the result?
@Houri93

@ghost
Copy link
Author

ghost commented Aug 3, 2017

@KSemenenko
yes .. have a look here, also sorry for being late .. and here's the code im extracting the colors with .. all thanks to you ofcourse ..

`
var pal = _colorThief.GetPalette(AlbumArtImage.Image, 10, 10, false).ToList().OrderByDescending(a => a.Population).ToList();
this.View.BackgroundColor = UIColor.FromRGBA(pal.First().Color.B, pal.First().Color.G, pal.First().Color.R, pal.First().Color.A);

        UIColor newtint = null;
        for (int i = 1; i < pal.Count; i++)
        {
            var huediff = Math.Abs(pal.First().Color.ToHsl().H - pal[i].Color.ToHsl().H);
            var lightdiff = Math.Abs(pal.First().Color.ToHsl().L - pal[i].Color.ToHsl().L);
            var satDiffer = Math.Abs(pal.First().Color.ToHsl().S - pal[i].Color.ToHsl().S);
            if (huediff * (100 / 360.0) > 5 ||
                lightdiff * 100 > 5
               || satDiffer == 0)
            {

                newtint = UIColor.FromRGBA(pal[i].Color.B, pal[i].Color.G, pal[i].Color.R, pal[i].Color.A);

                break;
            }
        }

        waveformL = new CGColor((nfloat)(pal[1].Color.B / 255.0), (nfloat)(pal[1].Color.G / 255.0), (nfloat)(pal[1].Color.R / 255.0));
        waveformR = new CGColor((nfloat)(pal[2].Color.B / 255.0), (nfloat)(pal[2].Color.G / 255.0), (nfloat)(pal[2].Color.R / 255.0));

        if (newtint != null)
        {
            this.timeLB.TextColor =
              this.titleLB1.TextColor =
              this.titleLB2.TextColor =
              this.View.TintColor =
              this.loading.Color =
                      newtint;


            if (pal.First().IsDark)
            {
                UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, true);

            }
            else
            {
                UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.Default, true);
            }
        }`

whatsapp image 2017-08-03 at 1 57 35 pm
whatsapp image 2017-08-03 at 1 57 36 pm
whatsapp image 2017-08-03 at 1 57 37 pm 1
whatsapp image 2017-08-03 at 1 57 37 pm
whatsapp image 2017-08-03 at 1 57 38 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant