From: Ramon F Herrera on

I think some Photoshop experts probably know how to do this....

I have an existent spreadsheet that has 3 shades of blue. I am writing
a program to generate spreadsheets similar to that one. The
application is based on the ExcelFormat SDK which contains hexadecimal
color definitions.

I can "click-pick" the RGB color components with Photoshop, but how do
I convert it to the hex format expected by Excel?

TIA,

-Ramon

----------------------------------------------------------

// predefined Excel color definitions
enum EXCEL_COLORS {
EGA_BLACK = 0, // 000000H
EGA_WHITE = 1, // FFFFFFH
EGA_RED = 2, // FF0000H
EGA_GREEN = 3, // 00FF00H
EGA_BLUE = 4, // 0000FFH
EGA_YELLOW = 5, // FFFF00H
EGA_MAGENTA = 6, // FF00FFH
EGA_CYAN = 7 // 00FFFFH
};

From: Ragnar on
Entering "convert rgb to hex" in Google brings up a millions hits including
http://www.javascripter.net/faq/rgbtohex.htm
HTH
R.

"Ramon F Herrera" <ramon(a)conexus.net> wrote in message
news:aa3ccd5e-89b7-49dc-9e3e-1acccf74cc24(a)5g2000yqj.googlegroups.com...
>
> I think some Photoshop experts probably know how to do this....
>
> I have an existent spreadsheet that has 3 shades of blue. I am writing
> a program to generate spreadsheets similar to that one. The
> application is based on the ExcelFormat SDK which contains hexadecimal
> color definitions.
>
> I can "click-pick" the RGB color components with Photoshop, but how do
> I convert it to the hex format expected by Excel?
>
> TIA,
>
> -Ramon
>
> ----------------------------------------------------------
>
> // predefined Excel color definitions
> enum EXCEL_COLORS {
> EGA_BLACK = 0, // 000000H
> EGA_WHITE = 1, // FFFFFFH
> EGA_RED = 2, // FF0000H
> EGA_GREEN = 3, // 00FF00H
> EGA_BLUE = 4, // 0000FFH
> EGA_YELLOW = 5, // FFFF00H
> EGA_MAGENTA = 6, // FF00FFH
> EGA_CYAN = 7 // 00FFFFH
> };
>


From: Ramon F Herrera on
On Apr 8, 2:55 am, "Ragnar" <rag...(a)NOSPAM.com> wrote:
> Entering "convert rgb to hex" in Google
> brings up a millions hits including
> http://www.javascripter.net/faq/rgbtohex.htm

Thanks!

> HTH

It definitely does...

-Ramon


From: Andrew Morton on
Ramon F Herrera wrote:
> I have an existent spreadsheet that has 3 shades of blue. I am writing
> a program to generate spreadsheets similar to that one. The
> application is based on the ExcelFormat SDK which contains hexadecimal
> color definitions.
>
> I can "click-pick" the RGB color components with Photoshop, but how do
> I convert it to the hex format expected by Excel?

"Click-pick" the colour then click the foreground colour in the tools
palette. The RGB representation is in the box at the bottom of the dialog.

--
Andrew


From: Ramon F Herrera on
On Apr 8, 5:41 am, "Andrew Morton" <a...(a)in-press.co.uk.invalid>
wrote:
> Ramon F Herrera wrote:
> > I have an existent spreadsheet that has 3 shades of blue. I am writing
> > a program to generate spreadsheets similar to that one. The
> > application is based on the ExcelFormat SDK which contains hexadecimal
> > color definitions.
>
> > I can "click-pick" the RGB color components with Photoshop, but how do
> > I convert it to the hex format expected by Excel?
>
> "Click-pick" the colour then click the foreground colour in the tools
> palette. The RGB representation is in the box at the bottom of the dialog..
>
> --
> Andrew


Thanks, Andrew:

Your tip certainly removes one level of uncertainty. I compared both
methods (yours and the one suggested by Ragnar) and they give the same
results. The world makes sense, for a change. :-)

Back to my original problem: it seems that the library I use to create
Excel spreadsheets programmatically can only deal with 16-bit colors,
and Microsoft -always so shrewd- uses the nicer shades to stay one
step ahead of the competition (read: open source solutions).

See below the colors that come with the "ExcelFormat" library and the
3 that I would like to use.

Thanks,

-Ramon

------------------------

Note: the values below are shifted to convert them to 2 bytes (16 bit)
values.

enum EXCEL_COLORS {
EGA_BLACK = 0, // 000000H
EGA_WHITE = 1, // FFFFFFH
EGA_RED = 2, // FF0000H
EGA_GREEN = 3, // 00FF00H
EGA_BLUE = 4, // 0000FFH
EGA_YELLOW = 5, // FFFF00H
EGA_MAGENTA = 6, // FF00FFH
EGA_CYAN = 7 // 00FFFFH
/*
LIGHT_BLUE = xDBE5F1, // DBE5F1H Ok
MEDIUM_BLUE = xB8CCE4, // B8CCE4H Ok
DARK_BLUE = x4F81BD // 4F81BDH Ok
*/
};