Canvas.Brush.Color and user defined color constants

Hi,

I've defined my own color constants like these:

const
  rmcAliceBlue = $FFF0F8FF;
  rmcAntiqueWhite = $FFFAEBD7;
  rmcAquamarine = $FF7FFFD4;
  rmcArmyGreen = $FF669966;
  rmcAutumnOrange = $FFFF6633;
  rmcAvocadoGreen = $FF669933;
  rmcAzure = $FFF0FFFF;
  rmcBabyBlue = $FF6699FF;
  rmcBananaYellow = $FFCCCC33;

When using one of those constants with Canvas.Brush.Color this mostly
results in black colors on the canvas.

How can I use those constants correctly or is it impossible to use user
defined colors at all?
-- 
cu,
Michael
0
Michael
10/31/2008 9:54:07 AM
embarcadero.delphi.graphics 928 articles. 0 followers. Follow

7 Replies
1741 Views

Similar Articles

[PageSpeed] 57

On Fri, 31 Oct 2008 02:54:07 -0700, Michael Fritz wrote:

> I've defined my own color constants like these:

>   rmcAvocadoGreen = $FF669933;

> How can I use those constants correctly or is it impossible to use user
> defined colors at all?

colors consist of Red, Green and Blue components in the format:
$rrggbb so for example Avocado Green might be:
  rmcAvocadoGreen = $669933

-- 
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
0
Marc
10/31/2008 11:39:50 AM
"Marc Rohloff" wrote in message <news:36736@forums.codegear.com>:

> colors consist of Red, Green and Blue components in the format:
> $rrggbb so for example Avocado Green might be:
>   rmcAvocadoGreen = $669933
Thanks Marc,

I assumed the same, however when looking at this example

	rmcBrown = $FFA52A2A;

and doing an xor $FF000000 before, to eliminate the first byte, I do get a
blue painted rectangle instead of a brown one.

-- 
cu,
Michael
0
Michael
10/31/2008 12:21:02 PM
Michael Fritz wrote:

> "Marc Rohloff" wrote in message <news:36736@forums.codegear.com>:
> 
> > colors consist of Red, Green and Blue components in the format:
> > $rrggbb so for example Avocado Green might be:
> >   rmcAvocadoGreen = $669933
> Thanks Marc,
> 
> I assumed the same, however when looking at this example
> 
> 	rmcBrown = $FFA52A2A;
> 
> and doing an xor $FF000000 before, to eliminate the first byte, I do
> get a blue painted rectangle instead of a brown one.

Correct the format is BGR not RGB and the Hex value you are giving has
4 bytes in it not 3 this meens that an extra byte is used which can not
be shown properly as transparency.
If I remember correctly this global in windows. 

Regards
Yannis.
-- 
"Any word you have to hunt for in a thesaurus is the wrong word."
- Stephen King
0
IOANNIS
10/31/2008 12:48:57 PM
"YANNIS KOZIKOPULOS" wrote in message <news:36754@forums.codegear.com>:

> Correct the format is BGR not RGB and the Hex value you are giving has
> 4 bytes in it not 3 this meens that an extra byte is used which can not
> be shown properly as transparency.
> If I remember correctly this global in windows. 
Thanks Yannis for your comment.

I've solved this now, this way:

I drop the very first byte $FF and swap the rest of the bytes to get a
result e.g. 2a 2a a5. This correctly shows the color now.

-- 
cu,
Michael
0
Michael
10/31/2008 1:04:45 PM
On Fri, 31 Oct 2008 05:48:57 -0700, YANNIS KOZIKOPULOS wrote:

> Correct the format is BGR not RGB and the Hex value you are giving has
> 4 bytes in it not 3 this meens that an extra byte is used which can not
> be shown properly as transparency.

The $FF in the first byte indicates a system color not tanspaency.

-- 
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
0
Marc
10/31/2008 4:39:12 PM
"Michael Fritz" <spam_athome@yahoo.de> wrote in message 
news:36716@forums.codegear.com...

> I've defined my own color constants like these:
<snip>
> When using one of those constants with Canvas.Brush.Color
> this mostly results in black colors on the canvas.

All of those values have the high bit of the high byte set to 1, which flags 
them as system colors.  When the VCL uses a system color for any reason, it 
has to call GetSysColor() to translation it to an actual RGB value.  In this 
case, none of your values are valid system colors, so GetSysColor() returns 
0, which is the same as Black.

> How can I use those constants correctly or is it
> impossible to use user defined colors at all?

You can use your own colors.  Just don't set the high bit of the high byte 
to 1, ie:

const
    rmcAliceBlue = $00F0F8FF;
    rmcAntiqueWhite = $00FAEBD7;
    rmcAquamarine = $007FFFD4;
    rmcArmyGreen = $00669966;
    rmcAutumnOrange = $00FF6633;
    rmcAvocadoGreen = $00669933;
    rmcAzure = $00F0FFFF;
    rmcBabyBlue = $006699FF;
    rmcBananaYellow = $00CCCC33;

-- 
Remy Lebeau (TeamB)
0
Remy
10/31/2008 5:17:35 PM
"Marc Rohloff" <marc@nospam.marcrohloff.com> wrote in message 
news:36856@forums.codegear.com...

> The $FF in the first byte indicates a system color not tanspaency.

More accurately, only the high bit of the byte indicates a system color. 
The rest of the bits are ignored

-- 
Remy Lebeau (TeamB)
0
Remy
10/31/2008 5:18:00 PM
Reply:

Similar Artilces:

How to change the highlighted color of the selected item using user defined color instead of window system color
Thx, JJ You'd have to create your own "selection" system... you can use a rectangle object and change its visibility as needed to simulate a highlighted row, but you'd have to have (and use) your own versions of SelectRow() and its kin. "JJ" <jasonyklau@sinaman.com> wrote in message news:41205c89@forums-1-dub... > Thx, > JJ > > Why do your own selectRow()? If I'm not wrong, coding this is the visible property should work: "if(getRow()=selectedRow(),1,0)" hth, JMR > You'd have to create your own...

C# Graphics.Clear(Color color) did not update color!
Hi, I have code that resizes an image and fills border spaces with certain color. This works fine, but when i changed the original color to a different one it still fills it with the original color. I rebuilt and built my project to try and get it to update right, but it still uses the original color. Any suggestions will be very much appreciated. E  Are you using any dll for doing that. If so mention the dll name , you can post your code here not the full one the part where there is a trouble.usually the syntax "Graphics.fill(Color color)" to update c...

User defined colors
We want to allow the user to be able to define their own colors for our PB app. Does anyone have a methodology so the user can define the colors for a PB app WITHOUT using the windows numonics, such as buttonface, background, etc? Storing the color values are not an issue, but the only 2 ways I can figure out how to set the colors in the pb/dw objects is the following: 1. write a series of global functions that lookup and return the appropriate color for a pb/dw object such as f_column_background(), f_text_foreground(), f_window_background(), etc. And then modify the code to...

superreview granted: [Bug 419167] right/left borders don't adopt user-defined color (colour) scheme (untick 'Allow pages to choose their own colors') : [Attachment 305371] patch without the array
David Baron [:dbaron] <dbaron@mozilla.com> has granted superreview: Bug 419167: right/left borders don't adopt user-defined color (colour) sche= me (untick 'Allow pages to choose their own colors') https://bugzilla.mozilla.org/show_bug.cgi?id=3D419167 Attachment 305371: patch without the array https://bugzilla.mozilla.org/attachment.cgi?id=3D305371&action=3Dedit ------- Additional Comments from David Baron [:dbaron] <dbaron@mozilla.com> r+sr=3Ddbaron.=0D =0D Why don't we just get this one in and I'll worry about converting this code over later...

how to set brushes.color from a color code (#d2d2d2)
 Hi,Currently in my code I set my brush color by going fontColor = Brushes.Red  Is there a way I can set the color from a font color code such as #d2d2d2 ? Thanks very much! mike123 If you use a SolidBrush, you can declare your own color. (SolidBrush inherits the Brush class, so the SolidBrushes can be treated as Brushes) Use the ColorTranslator class to create a color from hex code.  ' Imports at the top of the page Imports System.Drawing Dim myBrush As New SolidBrush(ColorTranslator.FromHtml("#d2d2d2")) ' use the solid brush as normal. --...

Converting System.Drawing.Color to Brushes.Color?
I'm trying to get text input from the user and assigning it straight to a brush. So if they entered "Maroon", the variable brTemp of type Brush would be assigned the value Brushes.Maroon Maybe I'm not thinking right, but is there an easy way to do this? I don't think a long case statement would be a very elegant solution. Drawing.Color has FromArgb, FromKnownColor, and FromName methods, but Brushes.Color doesn't seem to have anything like that. I'd even settle for RGB values entered by the user. When you are typing, say:Brush myBrush = Brushes.SlateBlue; basically all...

About colors
Hi In some of our DW, we change the background color of every alternate row to make the DW more readable (huge list) The main color is 'windows backgroud' ( = 1073741824) , and the alternate color is "a_little_bit_more_grey_than_windows_background" The thing is : to define alternate color, I need to know the RGB value of 'windows background'. At the moment, i take this value from the registries, but I cannot really trust that method as users could have a different registry setting ( you never know...). I had a problem on a test machine where the windows c...

Color by color in DataList
I use the DataList, and I want to set the background color in each item in a random way, anybody help me ? Thank in advancedMSN: unfriendlyboy@hotmail.comASP.NET fan. You can set the background color of items in the DataList in ItemCreated. This method is called as each item is created. Within your ItemCreated method, you can use e.Item.BackColor to set the background color. To randomize the colors, take a look at the Random class. You'd probably want to use one of the "Next" overrides to generate your color number or numbers.JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Lea...

Color Palette for user to select color at runtime on a web form
Hello friends Is is possible to pop up a color palette,on a button click for the user to select a color from the palette on a WEB FORM. It is possible on a windows forms, but currently i am looking for a WEB FORM based color palette. Let me know , if any one know the exact API. Sincerely Nihar There is no such buit in thing in asp.net, you will have to create your own browserbased colorpicker. Search in google will give you lot of third partycolor picker in asp.net some of them are free and some of then charge money but you can take idea and build your own.Jig...

ASP.NET-How to create [User Control], whose properties is color, and we can chose its color in panel of properties?
Im a beginner in Asp.net, and I have met many difficulties (perhaps all of they is fundamental )! Plz !!!!!! You can add a public property for the color and access it in the code-behind. However properties won’t appear in the designer for User Controls (at least I haven't found a way yet). They will for custom server controls.Brian PriceCo-Author of UCanUse ProductsUCanUse.comWittysoft, LLC Yeah adding a public property is not enought for user control ! this called "the color picker drop-down list". I think it is very fundamental, but i don't know where I can find document ...

32Bit Color / 16Bit Color
Our applications uses graphs. We recently found that if the client system was set to True Color(32Bit)all graphs display without color but with various types of lines. Change the client to High Color(16 Bit) and all is well! Is there any solution other than switching the individual system to utilize 16bit color? Any help appreciated! Thanks! -- http://www.genesis-software.com jdouglas@genesis-software.com We found this too, the answer from PowerSoft was 'No'! Jim Douglas wrote in message <6ia2ss$agq@bgtnsc03.worldnet.att.net>... >Our applica...

Celendar Colors and Category Colors
Hi, using Sunbird 0.5, I wonder how I could swap the colors used for displaying the category and calendar. This means currently I get a box filled up with the color of the calendar, surrounded by a rectangle colored in the category color. I simply would like to swap both colors since I can differentiate better e.g. if this is a birthday event or a private event. For now you have to look very closely since all events look more or less the same because of the small used border with used to display the category. Is there an option for this? Thanks! -- cu, Michael On Aug 3, ...

Coloring my own keywords, (Syntax Colors)
How can I get the editor to highligth keywords like WInt WULong... Jostein. ...

Color converter mixes colors up
I am trying to make the colors of certain controls databound. The colors are in a database in long format. For exampleLong: 16711680which I took with a color picker and is dark blue (#0000FF)A function which I took from the net converts the long rightly to 0000FF. However:Dim converter As New System.Drawing.ColorConverterDim hiscoloris As Drawing.Color = converter.ConvertFromString(-the long value casted to int32-)Dim htmlstring As String = System.Drawing.ColorTranslator.ToHtml(hiscoloris)Dim anothercolor As Drawing.Color = System.Drawing.Color.FromArgb(hisintis)seems to reverse the string: ...

Web resources about - Canvas.Brush.Color and user defined color constants - embarcadero.delphi.graphics

Fine-structure constant - Wikipedia, the free encyclopedia
In physics , the fine-structure constant (usually denoted α , the Greek letter alpha ) is a fundamental physical constant , namely the coupling ...

Generation ranked: GPY&R research finds constant tracking of today's teens
When advertising and marketing firm GPY&amp;R delved into the lives of 14- to 17-year-olds, they discovered a generation driven by metric analysis ...

Evasion the only constant in tax changes
The purpose of raising the GST by 5 per cent % is to raise additional revenue and reduce the budget deficit (&quot;GST rise shown to hit poorest ...

Rising bank returns 'not a constant of the universe': Glenn Stevens
RBA governor Glenn Stevens told bank shareholders to prepare for a future of lower returns, saying rising returns cannot "simply be accepted ...

2.9M Drone Shipments, Constant Sensing Among CES Tech Trends
The annual Consumer Electronics Show in Las Vegas always kicks off with a couple of overview sessions for press at the Mandalay Bay hotel, covering ...

James Middleton: ‘As a businessman I am reported as a constant failure’
... success. You can read the full piece here . Some highlights: James wants to be taken seriously: “As a businessman I am reported as a constant ...

Ben Carson, Glenn Beck, and the Constant Effort to Rewrite History
People like Cleon Skousen will always be able to make a buck in America, because people like Carson and Beck will believe him. They just need ...

'Arrow' Star Colton Haynes Opens Up About Life-Long Battle With 'Intense Anxiety': 'It's Been a Constant ...
'Arrow' Star Colton Haynes Opens Up About Life-Long Battle With 'Intense Anxiety': 'It's Been a Constant Struggle'

Frederic Kerrest on Building Business by Maintaining a Constant Dialogue with Customers
... for the company and its customers. Frederic shared valuable insights on building a business, understanding customers, and maintaining a constant ...

Five Strategies To Get Constant Promotions
What's the secret to getting to the C-suite? Being self-critical, self-aware, and keeping your ego in check. Climbing the career ladder doesn't ...

Resources last updated: 1/18/2016 1:10:05 PM