|
 |
aspx thread: Setting Colors in system.Drwaing
Message #1 by "Hugh McLaughlin" <hugh@k...> on Wed, 8 May 2002 19:38:08
|
|
Hello Everyone and thanks for your help in advance. Most
of the examples for System.Drawing use the following
syntax for setting background colors:
MyNewGraphic.Clear(Color.Blue)
But I cannot find an example to set the color using hex
codes such as: #ffcc66. How is this done?
Also, I have tried making a background trasparent using:
Dim backColor As Color = MyNewBitmap.GetPixel(1, 1)
MyNewBitmap.MakeTransparent(backColor)
But for some reason, this causes the bitmap to be black.
Any help on these issues would be greatly appreciated.
Thanks.
.
Message #2 by Scott Mitchell <mitchell@4...> on Wed, 08 May 2002 11:47:22 -0700
|
|
Use Color.FromArgb(int,int,int)
see:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdrawingcolorclassfro
margbtopic3.htm
So you could do:
Color.FromArgb(255, 204, 102)
// equiv to #ffcc66
(I used Window's calculator to translate between Hex and Decimal.)
Scott Mitchell
mitchell@4...
http://www.4GuysFromRolla.com/
http://www.ASPMessageboard.com/
http://www.ASPFAQs.com/
* When you think ASP, think 4GuysFromRolla.com!
| -----Original Message-----
| From: Hugh McLaughlin [mailto:hugh@k...]
| Sent: Wednesday, May 08, 2002 7:38 PM
| To: ASP+
| Subject: [aspx] Setting Colors in system.Drwaing
|
|
| Hello Everyone and thanks for your help in advance. Most
| of the examples for System.Drawing use the following
| syntax for setting background colors:
|
| MyNewGraphic.Clear(Color.Blue)
|
| But I cannot find an example to set the color using hex
| codes such as: #ffcc66. How is this done?
|
| Also, I have tried making a background trasparent using:
|
| Dim backColor As Color = MyNewBitmap.GetPixel(1, 1)
| MyNewBitmap.MakeTransparent(backColor)
|
| But for some reason, this causes the bitmap to be black.
|
| Any help on these issues would be greatly appreciated.
| Thanks.
| .
|
Message #3 by Feduke Cntr Charles R <FedukeCR@m...> on Wed, 8 May 2002 14:48:16 -0400
|
|
Although the documentation apparently says different or seemingly
nothing of it...
Color.FromName("#ffcc66"); // MS - maybe an int overload here or something?
is a valid statement, and will generate the expected results.
The problem you *might* be having with transparency with your bitmap
is BitMaps don't inheritantly support alpha channels/transparency. Try
converting your BitMap to to another type that does support transparency
(like PNG or GIF if either is available).
HTH,
- Chuck
-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...]
Sent: Wednesday, May 08, 2002 3:38 PM
To: ASP+
Subject: [aspx] Setting Colors in system.Drwaing
Hello Everyone and thanks for your help in advance. Most
of the examples for System.Drawing use the following
syntax for setting background colors:
MyNewGraphic.Clear(Color.Blue)
But I cannot find an example to set the color using hex
codes such as: #ffcc66. How is this done?
Also, I have tried making a background trasparent using:
Dim backColor As Color = MyNewBitmap.GetPixel(1, 1)
MyNewBitmap.MakeTransparent(backColor)
But for some reason, this causes the bitmap to be black.
Any help on these issues would be greatly appreciated.
Thanks.
.
|
|
 |