473,387 Members | 1,664 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,387 software developers and data experts.

inverse color

How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?

0 0 255
- 255 255 255
==============
-255 -255 0

ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!
Jul 26 '06 #1
3 7074
hi Smokey

Dim OriginalColor As Color = Color.RoyalBlue
Dim InverseColor As Color = Color.FromArgb(Not OriginalColor.R,
Not OriginalColor.G, Not OriginalColor.B)

-t

Smokey Grindle ha scritto:
How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?

0 0 255
- 255 255 255
==============
-255 -255 0

ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!
Jul 26 '06 #2
Switch the operators in the subtraction, and you don't get a negative value:

255 - r, 255 - g, 255 - b

You can also use exclusive or:

r xor 255, g xor 255, b xor 255
Smokey Grindle wrote:
How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?

0 0 255
- 255 255 255
==============
-255 -255 0

ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!

Jul 27 '06 #3
Smokey Grindle wrote:
How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?
Not sure, but be aware that by this rule the inverse of medium gray
(808080) is... another medium gray (7f7f7f)
>
0 0 255
- 255 255 255
==============
-255 -255 0
Subtract the other way round.
>
ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!
If there were such a method it would be in Color, I imagine, and there
isn't one there. You might find a recent thread we had here about RGB -
HSL conversion interesting.

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jul 27 '06 #4

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

Similar topics

6
by: David C. Fox | last post by:
Is there a function which takes a list of tuples and returns a list of lists made up of the first element of each tuple, the second element of each tuple, etc.? In other words, the the inverse...
1
by: Andy | last post by:
I have drawn an icon. I used the the inverse color on the color window in order to get transparency. However, now the inverse color has stopped working by some reason. Why is this? I press and...
6
by: vishnu mahendra | last post by:
hello to all, can any one please give me an algorithm to find inverse of a matrix of order n rows and m columns. thank you in advance, vishnu.
9
by: Water Cooler v2 | last post by:
What is the inverse of the sine function? I've been pulling my hair and I have no clue nor memory of how to go about solving this little expression: sine-1 (read sine inverse) of (1-(x/y)) An...
6
by: Randy | last post by:
Hello, Can someone tell me how to derive the Inverse of Math.Log10(value)? Thanks
5
by: Mario | last post by:
How do I get the inverse of a cosine, that is, cos(a) = x, I have x and I need to know a? I don't need the hyperbolic inverse, unless I can use it to get the cosine inverse. Greetings, Mario
2
by: Carl Gilbert | last post by:
Hi I am having difficulty calculating an angle using VB.NET I have calculated opposite over adjacent but can not get the angle from this value. Example on a calculator: Tan-1(1.234)=51...
59
by: pamelafluente | last post by:
Hi, If I have: <div style="background:anyColorHere"Hi </div> where anyColorHere is any hex string that represent a valid color. How can I invert that background color "anyColorHere" ? Can...
4
by: Jonathan Fine | last post by:
Hello As part of the MathTran project I found myself wanting to maintain a bijection between long names and short names. http://www.open.ac.uk/mathtran In other words, I wanted to have two...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.