1

I want to have the backlight on my phone dynamically change intensity, even turning completely off during completely black screens and such. How possible is this? It's a nexus 5 running cataclysm 5.0.1 with elementalx kernel.

1

You could consider capturing an image of the screen, then processing that bitmap for the brightness of each pixel.

The Android Screenshot Library (ASL) should give you information on how to do a screen capture. This link on StackOverflow talks about how to do it as well, but the main link seems to be to the ASL.

To calculate the luminosity of the pixels, you could do it in either of the RGB or HSV color spaces. I think I'd do it in HSV, since the Value (the V in HSV) is the brightness of the pixel's color. You could also do it with the three color parameters in the RGB color space, but then you're working with ratios and you're having to perform more calculations yourself. With HSV you would (I think) simply add up all the Values and divide by the number of pixels. (Possibly you'd throw in a scalar if a linear change in brightness doesn't look quite right. Eg: Have a slower backlight change when you have bright graphics, but move more quickly towards no backlight when you have graphics approaching black.)

With that working, you might want to consider doing the work using Android's RenderScript. Processing graphics is what RenderScript was designed for, and it takes care of parallelism for you. You might as well use all the CPU / CPU / DSP cores you have available.

Finally, you might want to follow this up by getting tricky and using the device's light sensor information. After all, if you're going to dynamically change the backlight based on what is on the screen, you might as well also consider the ambient brightness around the device. :-)

I hope that helps!

Edit: I hope you were looking for a programming answer. I hadn't really thought about the fact that this question was posted to Android Enthusiasts instead of to Stack Overflow. :-)

  • 1
    I'll look into it...it might take a bit to figure out how to do all that but I think the idea of doing some sort...wait...what? Yes...I will be perfectly honest in my lack of understanding what exactly I need to do – sbergeron Jan 1 '15 at 23:28
  • If you're interested in learning to write software, having a project in mind is a good way to do it. This one could be good in that it covers several Android topics. If you could post what your programming experience is, I'd be happy to point you in a direction to get started. – Chris Jan 1 '15 at 23:32
  • I've managed to make a hello world android app...I have basic experience when it comes to lua...and I've unsuccessfully compiled an android rom...so yeah, poweruser not developer pretty much – sbergeron Jan 1 '15 at 23:47
  • 1
    Don't worry about the Android ROM compiling - that sort of thing is tricky for those that know their stuff. :) I'd suggest a Java tutorial (a quick one or a long one, depending on your needs) like learnjavaonline.org to get some of the Java basics you'd need. With your Android "hello world" success, I'd suggest building it in these steps: 1) load and display and image, 2) process that image to get the overall brightness, 3) adjust the backlight for that image. That breaks your task into some simpler ones that take you through image handling, processing, and backlight control. ... – Chris Jan 1 '15 at 23:54
  • 1
    Following the above: 4) learn how to make a background service, 5) learn how to do a screen capture, 6) put the code from steps 2 and 3 into your background service to process the image from step 5. – Chris Jan 1 '15 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.