Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

ColorsFromImage returns white only #89

Closed
coding-watermelon opened this issue Nov 25, 2015 · 7 comments
Closed

ColorsFromImage returns white only #89

coding-watermelon opened this issue Nov 25, 2015 · 7 comments

Comments

@coding-watermelon
Copy link

Hello,

the above function does not work on a given image, neither with both true and false for the parameter isFlatScheme. The AverageColor function works fine on the same image.

What could lead to this problem?

@vicc
Copy link
Owner

vicc commented Nov 26, 2015

@Sittenstrolch I just tried it on the following image and it worked fine. Can you post your code so I can see what you're doing?

screen shot 2015-11-25 at 10 36 42 pm

I added my code below, including the image I used.

self.imageView.image = [UIImage imageNamed:@"lambo.jpg"];
NSArray *colors = [NSArray arrayOfColorsFromImage:self.imageView.image withFlatScheme:NO];
self.view1.backgroundColor = colors[0];
self.view2.backgroundColor = colors[1];
self.view3.backgroundColor = colors[2];
self.view4.backgroundColor = colors[3];
self.view5.backgroundColor = colors[4];

@coding-watermelon
Copy link
Author

@ViccAlexander I think the main difference is that im using swift2.

I'm fetching the images from a url and pass them into a callback function. The images are displayed correctly and the average Color also works fine. But the ColorsFromImage returns white only.

This is how I integrated your Pod into my Project:

pod 'ChameleonFramework/Swift'

My Code:

{ 
image in
  let palette = ColorsFromImage(image, true)
  print(palette)
  let avgColor =  AverageColorFromImage(image)
  print(avgColor)
}

I tried to call the function with true and false as second parameter, but it made no difference.

And the output is:

[
  UIDeviceWhiteColorSpace 1 1, 
  UIDeviceWhiteColorSpace 1 1, 
  UIDeviceWhiteColorSpace 1 1, 
  UIDeviceWhiteColorSpace 1 1, 
  UIDeviceWhiteColorSpace 1 1
]
UIDeviceRGBColorSpace 0.0431373 0.247059 0.188235 1

And here is the image, the output was created from:
385

@bre7
Copy link
Collaborator

bre7 commented Nov 27, 2015

@Sittenstrolch Could you try the same example in both objc and swift ? This shouldn't be the issue since swift functions are only shorthands

@coding-watermelon
Copy link
Author

I honestly don't really know how to use objective-c within my swift project. Have you tried it with swift?

@bre7 bre7 closed this as completed in 0d0d59f Nov 30, 2015
@bre7
Copy link
Collaborator

bre7 commented Nov 30, 2015

My bad ✋ Fixed it... Thanks for the report @Sittenstrolch, try using :head in CocoaPods/carthage until 2.0.6
@ViccAlexander bump version with this fix when you can.

Flat / Non-flat

@vicc
Copy link
Owner

vicc commented Nov 30, 2015

@bre7 Gotcha. @Sittenstrolch Chameleon 2.0.6 is now available. Updating should fix your issue. 👍

@coding-watermelon
Copy link
Author

Great! It works ;)

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

No branches or pull requests

3 participants