|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
inverse colorHow 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! 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: Show quoteHide quote > 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! 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: Show quoteHide quote > 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! > > Smokey Grindle wrote:
> How can you "inverse" a color in GDI+? Say the color I have is blue, the Not sure, but be aware that by this rule the inverse of medium gray > 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? (808080) is... another medium gray (7f7f7f) > Subtract the other way round.> 0 0 255 > - 255 255 255 > ============== > -255 -255 0 > If there were such a method it would be in Color, I imagine, and there > ABS(result) = 255,255,0 > > ? or am i going the wrong way with this and there is an easier way. thanks! isn't one there. You might find a recent thread we had here about RGB - HSL conversion interesting. -- Larry Lard larryl***@googlemail.com The address is real, but unread - please reply to the group For VB and C# questions - tell us which version
VB Code question
At least one object must implement IComparable How to create multiple threads? Parsing Files with Regular Expressions Compiling VB (.NET) files located in different directories Anyone can help me?£¬How to Convert C# to VB.NET, about Flood Fill Suppressing redraw of PictureBox after moving? Can WinCE & Pocket PC support the "AsyncCallback"? DataGridTableStyle How to launch program from CD after vb deployment installed |
|||||||||||||||||||||||