7

This Question Here was marked a duplicate because the wording of the question was bad. But I have the same question.

I do not want to change the brightness of the screen but change the color temperature of the screen the way the app f.lux does. It eliminates blue light at night time.

Unfortunately, the API it uses is not App Store admissible. But I'm a developer, so as long as I can get the app on my personal devices I would like to write it so I don't have to jailbreak my phone.

Any idea what calls they may be making to tint the entire screen so there is little to no blue light even when in the background?

Community
  • 1
  • 1
tettoffensive
  • 664
  • 7
  • 24
  • The [`CITemperatureAndTint`](https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CITemperatureAndTint) filter can do what you want to an image. I don't know how you would apply it to the whole screen, though. – user1118321 Jan 23 '14 at 05:27
  • no, but i really haven't been looking into it since it's for a side project that i haven't had time for lately – tettoffensive Jan 23 '15 at 03:32
  • you can now use f.lux as an app developer: https://justgetflux.com/sideload/ – tettoffensive Nov 11 '15 at 21:37
  • and now, it's built into iOS 9.3 (called NightShift) – tettoffensive Jan 12 '16 at 02:31

2 Answers2

2

Looking at the flux sources with nm gives some hints, it loads:

/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer

And references these symbols:

U _IOMobileFramebufferGetGammaTable
U _IOMobileFramebufferGetMainDisplay
U _IOMobileFramebufferSetColorRemapMode
U _IOMobileFramebufferSetGammaTable

A more complete disassembly is provided here:

https://gist.github.com/anthonya1999/e0bffcac15b6b208126d

alfwatt
  • 2,010
  • 2
  • 18
  • 29
0

I guess HUE is the property which corresponds to the color temperature , i was successful changing the hue of an UIImage the below code does the same, i guess this will not exactly answer your question but will give you an idea to get started,

//convert to HSB
CGFloat h, s, l, a;
UIColor *color = [UIColor colorWithRed:r green:g blue:b alpha:1.0f];  
[color getHue:&h saturation:&s brightness:&l alpha:&a];

//adjust hue
h *= amount;

//convert back to RGB
color = [UIColor colorWithHue:h saturation:s brightness:l alpha:1.0f];
[color getRed:&r green:&g blue:&b alpha:&a];

This will need some twist to set it in your code.

spider1983
  • 1,098
  • 1
  • 7
  • 14
  • 1
    Thanks, you are right that it corresponds to hue and I no how to adjust it in my app as you have shown. But what I'm really wondering is how they change the hue for the phone's screen itself so that it persists even outside the app. – tettoffensive Jan 24 '14 at 05:10