Datatribe Softwerks, Ltd.

<< Ext.nd: Alpha Demo at ILUG | Home | Template: DomLedger>>

Notes: Custom Colors?

Thu 24 May 2007

Submitted by: Mark Barton

Ever created your own custom colors in notes? Then lost them between sessions? :-(

It turns out they're stored in your Notes ini as the following - CustomColor1=FDF5EE, CustomColor2=F0D9C2 etc.

How cool is that? It means you can have your corporate colors rolled out via your ini file :-)

Thanks, Mark! Ah the good old ini file. Takes me back to hacking the demo version of Doom to allow you to play all levels via one little line in the ini.... or was it Quake?

Cross Reference: Color Picker

Comments are currently disabled. Feel free to use the contact form.

Reader Contributions:

Mark Barton (25/05/2007 02:13) e-mail

Forgot to mention the Red and Blue are reversed. Why I don't know.

So if you want red it needs to be FFFF00 rather 00FFFF

Jerry (25/05/2007 19:27)

Hm. B G R instead of R G B? that is odd.

Still a cool tip.

Charles Robinson (07/05/2007 07:25 PM) website / e-mail

The reason RGB is reversed on Windows is because the byte order on Intel CPU's is little endian. Microsoft decided that Red would be 255 (0x000000FF as a 32-bit hex number), so this forces the R component to be the rightmost byte of a color value. In order to get the internal representaion to mimic a big endian system, Red would have to be 4,278,190,080 (0xFF000000).

Jerry (05/07/2007 19:48)

Hey Charles,

Thanks for stopping by!

I understand what you are saying but I don't think that's exactly the case.

Windows colors are acutally in R G B order. IBM has it (within Notes at least) B G R. The only bigendian systems I am aware of are Motorola chips, e.g. Macs, Amigas

Red, so far as I know isn't 000000FF because red neccessarily = 255. Each chanel is 000 to 255 (or 1 to 256 if you are thinking in an 8 bit literal 1-8 sense). Depending on your rendering pallet, red is FF0000 where the Red register is 255, green is 000 and blue is also 000. HTML colors are represented this way.

If you are using a png pallet, you have ARGB - A being alpha transparency - which gives us the ability to have transparent png's.

It's not that FF is 255 way down at the begining of the little-endian binary - all three (or four) color registers use 000 - 255. Color values with alpha can be stored on a 32 bit byte for sure.

I'm not 100% sure though that when that is done it falls out as, your example taken, 000000FF for red exactly. Sources I've consulted seem to use the AARRGGBB format, so red would be stored as 00FF0000 and then the color values bit-shifted out or otherwise multiplied out for rendering / interpretation by the rendering layer.

Microsoft may have made a pallet determination in windows BMP format that colors are stored as you indicate, but I don't think that would explain IBM' use. Everyone else tends to stick to the Television (NTSC) standard RGB ordering.

Charles Robinson (07/06/2007 06:03 AM) website / e-mail

I had a lengthy discussion with a friend about this last night before I gave the answer above. I'll see if I can get him to respond directly, he does lots of low level graphics work.

Charles Robinson (07/06/2007 11:58 AM) website / e-mail

Okay, I have more info, and we're both sorta on different points.

Notes is using the standard Windows color picker that is exposed via the ChooseColor API. This includes a return value that is the RGB value the user selected. Lotus is applying this value to the design element, then converting it to hex and flipping it to BGR to store it in the notes.ini. It makes no sense to go out of their way to flip it around to store it, so I'm baffled why it's reversed in the notes.ini. Maybe Notes started life on a big endian system and this stuck around?

For in-memory operations on Windows, Microsoft uses device independent bitmaps (DIB's). These are stored in memory uncompressed and aligned to memory boundaries. Microsoft decided to store the red component of a pixel in the low order byte. When you give a little endian CPU an integer the low order byte is on the left, not the right, which appears to reverse it. When this is read from memory it will retain the perceived reversal unless you force it to align along byte segments.

To test whether this is actually true you can take an integer representation in BGR and stuff it into a byte array and you get RGB.

Dim bytearray(3) As Byte
Dim color As Long

color = &HFF0000 'BGR
CopyMemory(bytearray(0), color, 4)
Forall num In bytearray
Print num
Next

The output will be 0 : 0 : 255 : 0, which is RGBA. :-)

Jerry (06/07/2007 15:20)

Cool! Excellent details.

Thank your friend for sharing, and thanks for following up. That could be useful to somebody someday... you never know!




May, 2007
SMTWTFS
  01 02 03 04 05
06 07 08 09 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Articles by Month
Articles by Category
Features Downloads
Recommended