3

I am working on an app that loads images from my server. These images are all different sizes. So I was wondering - it is possible to detect the background colour of an image or its most prominent colour?

The reason behind this is I would like the UIView behind the UIImage to change its background colour based on the UIImage. So for example say I have a UIImage that has an iPhone sitting on a blue table I would like to detect that colour blue and use it as the background colour for the UIView.

Is this at all possible?

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99
  • 3
    http://stackoverflow.com/questions/12147779/how-do-i-release-a-cgimageref-in-ios/12148136#12148136 – brandonscript May 22 '14 at 06:16
  • what you can do is get the **average color** of that `UIImage` and then set the `UIView`'s color to that **average Color** – Ahmed Z. May 22 '14 at 06:22
  • You can get average color using this method.. http://stackoverflow.com/a/13695592/1042240 – Ahmed Z. May 22 '14 at 06:22
  • Going on from this - is it possible to get the average colour for a part of the UIImage - say the left top corner or left side of the image? – Robert J. Clegg May 22 '14 at 07:03

0 Answers0