luminance

Kentman

Active Member
Joined
Apr 26, 2010
Messages
260
I can get a colour of a cell using Mycell.Interior.ColorIndex in a function but can I get the luminance?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Code:
Public Declare Function ColorRGBToHLS Lib "shlwapi.dll" ( _
                                      ByVal clrRGB As Long, _
                                      pwHue As Long, _
                                      pwLum As Long, _
                                      pwSat As Long) As Long
Sub demo()
    MsgBox GetLuminance(Selection.Cells(1).Interior.Color)
End Sub
 
Function GetLuminance(iColor As Long) As Long
    Dim iHue        As Long
    Dim iSat        As Long
    Dim iLum        As Long
 
    ColorRGBToHLS iColor, iHue, iLum, iSat
    GetLuminance = iLum
End Function
Returns values in the range 0 to 240.
 
Upvote 0
Kentman,


See:

Aaron Blood
The Luminance Formula:
R * 0.3 + G * 0.59 + B * 0.11 = L
http://www.ozgrid.com/forum/showthread.php?t=141215&page=1


http://spreadsheetpage.com/index.php/comments/exploring_theme_colors/


http://www.mvps.org/dmcritchie/excel/colors.htm
Color Luminance (#Luma)
In color television luminance is calculated (approximately) like this (1 = white, represented by 1V signal voltage):
L = R*0.3+G*0.59+B*0.11
This formula was created to make the color video signal compatible with black and white monitors/receivers. Monochrome monitors are still in use as professional viewfinders on many TV cameras, since they create a sharper image than one made from a color matrix. Posted by Harald Staff, plus the reference below.
Poynton ’s Color FAQ, Charles Poynton [alt] [archive] -- see item #9.
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,510
Members
452,918
Latest member
Davion615

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top