473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I calculate GetBrightness ny myself?

I know there is a function named GetBrightness() on .net framework but if I
need to write this function by myself, how can I do?

Because some language does not provide this function, can I calculate by
using R G B of the color?

Thanks
Oct 17 '06 #1
1 2268
Hi Dominic,

Using Lutz Roeder's Reflector, I see the following code under
System.Drawing.Color:

''' <summary>Gets the hue-saturation-brightness (HSB) brightness value for
this <see cref="T:System.Drawing.Color"></seestructure.</summary>
''' <returns>The brightness of this <see
cref="T:System.Drawing.Color"></see>. The brightness ranges from 0.0 through
1.0, where 0.0 represents black and 1.0 represents white.</returns>
Public Function GetBrightness() As Single
Dim single1 As Single = (CSng(Me.R) / 255!)
Dim single2 As Single = (CSng(Me.G) / 255!)
Dim single3 As Single = (CSng(Me.B) / 255!)
Dim single4 As Single = single1
Dim single5 As Single = single1
If (single2 single4) Then
single4 = single2
End If
If (single3 single4) Then
single4 = single3
End If
If (single2 < single5) Then
single5 = single2
End If
If (single3 < single5) Then
single5 = single3
End If
Return ((single4 + single5) / 2!)
End Function
MSDN article for more info:
http://msdn2.microsoft.com/en-us/lib...rightness.aspx

Hope this information helps,

Chris

"Dominic" <j_******@hotmail.comwrote in message
news:eK**************@TK2MSFTNGP04.phx.gbl...
>I know there is a function named GetBrightness() on .net framework but if I
need to write this function by myself, how can I do?

Because some language does not provide this function, can I calculate by
using R G B of the color?

Thanks

Oct 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
41
by: Saurabh Saxena | last post by:
can we calculate the 73! value in c or c++ without loss of significant digits.
5
by: brendanmcdonagh | last post by:
Hi, I have been learning VB now for about a week and thought I was doing ok. I have already done a calculation form (not as big as this) . I have volunteered myself to help a friend input her hours...
1
by: ekariuki | last post by:
Hallo, I have a table Routes that contains a route name and when the route runs. I would like to calculate the difference between the last run Day and the one after it. This will populate in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.