convert color to rgb

67 views
Skip to first unread message

Michael Hagl

unread,
Dec 10, 2021, 5:11:15 AM12/10/21
to
hi,
how can I convert a color value (1-255) to an RGB value?

I think I need an Array {{nColor, nRgbForegrundColor, nRgbBackgrundColor}} with 255 Lines. Im I right?

Thank you for some answers!

Michael Hagl

dlzc

unread,
Dec 10, 2021, 9:12:53 AM12/10/21
to
Good morning Michael:
https://www.dostips.com/forum/viewtopic.php?t=8493
... your problem in reverse.

It is just math. You parse the bits, and make them the highest order bits of the appropriate color. You can make an array, if you do this a lot.

David A. Smith

Ella Stern

unread,
Dec 10, 2021, 5:36:38 PM12/10/21
to
In case of desktop apps the RGB value is an integer (on 4 bytes). The formula is described here (it does not include alpha channel):
https://math.stackexchange.com/questions/1635999/algorithm-to-convert-integer-to-3-variables-rgb
...but I don't understand what you need. If you are generating html files, the hexa color codes are simpler.

Michael Hagl

unread,
Dec 13, 2021, 3:25:25 AM12/13/21
to
Hi Ella,

I need it for PageScript function PsTextOut()
Function PSTextOut(nTop, nLeft, xValue, cPicture, nJustify, cFontName, nFontSize, nFontStyle, nFontFColor, nFontBColor, nAngle)

nFontFColor, nFontBColor has to be RGB values. I want to convert Colorstring "b/n" t two RGB values.


Ella Stern schrieb am Freitag, 10. Dezember 2021 um 23:36:38 UTC+1:

timepro timesheet

unread,
Dec 13, 2021, 6:42:16 AM12/13/21
to
i simply use this, works ok:
xnb=rgb(0,0,128) - navy blue
xw=rgb(255,255,255) - white
pssetfont(fontname,fontstyle,fontsize,xnb,xw)
pstextout(xx,yy,'blah blah...')
...
Reply all
Reply to author
Forward
0 new messages