473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invert of background color

Hi,
I have color as System.Drawing. Color c1 object as background color.
Now I would like to get another System.Drawing. Color c2 object which
is invert of c1 color to be used as foreground color.
e.g if I have c1 as black and I should get c2 as white.
Thanks,

Mahesh

Apr 26 '07 #1
1 2884
Use

public Color Invert(Color inputColor)
{
byte r = (byte)~(inputCo lor.R);
byte g = (byte)~(inputCo lor.G);
byte b = (byte)~(inputCo lor.B);

return Color.FromArgb( inputColor.A, r, g, b);
}

WBR, Alex Meleta
Blog: http://devkids.blogspot.com
-----Original Message-----
From: ma************* *@gmail.com [mailto:ma****** ********@gmail. com]
Posted At: Donnerstag, 26. April 2007 21:37
Posted To: microsoft.publi c.dotnet.genera l
Conversation: Invert of background color
Subject: Invert of background color

Hi,
I have color as System.Drawing. Color c1 object as background color.
Now I would like to get another System.Drawing. Color c2 object which
is invert of c1 color to be used as foreground color.
e.g if I have c1 as black and I should get c2 as white.
Thanks,

Mahesh

Apr 26 '07 #2

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

Similar topics

10
2875
by: Des Small | last post by:
Lately I have found myself using a pattern to make new dictionaries quite often, by which I mean twice: def invert(d): nd = {} ).append(key) for k, v in d] return nd def count(l): d = {}
5
6010
by: Me Padre | last post by:
Hoping someone can help with this. I know I can do this programatically using a loop but I thought there might be some easier or more effective way. I am trying to invert an array. i.e. array1 = 1,2,3,4,5
3
25279
by: Peter Aitken | last post by:
I want to invert all the bits (all 0s to 1s, all 1s to 0s) in a type ushort. I though I would use the complement operator ~ but the compiler won't buy it. How can I do this? Thanks, -- Peter Aitken Remove the crap from my email address before using.
4
2043
by: Derek Martin | last post by:
Hi List, I have an arraylist of objects. I have created my own IComparable in the object to return the sort on datetime. This works great! Now, I'd like to invert the sort. Currently, it gives me 4/1/05 before 4/5/05 (good), but I'd like to have 4/5/05 before 4/1/05 (better!) for my application. Public Function CompareTo(ByVal obj As...
10
3710
by: rtilley | last post by:
s = list('some_random_string') print s s.reverse() print s s = ''.join(s) print s Surely there's a better way to do this, right?
41
3339
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
0
2222
by: Karthik | last post by:
Hi, I want to record a sound wave from a mic and at the same time invert it and play the inverted wave.My code goes as follows, however nothing is written into the E:\inverted.wav file.Thanks in advance for any help. from Tkinter import * root = Tk() import tkSnack tkSnack.initializeSnack(root)
2
1794
by: Stef Mientki | last post by:
hello, from the manual I read that a bitwise inversion should be done by invert. But from some experiments I see that not works equally well. Is this coincidence ? (The disadvantage of invert is that I've to import operators) thanks, Stef
3
2307
by: Oubez | last post by:
hi guys, I need to invert colors of a text box and its text that's background color of text area becomes the color of the characters and vice versa. I tryed this but it didn't work TextBox.BackColor = TextBox.ForeColor TextBox.ForeColor = TextBox.BackColor they both had the same color :S
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.