MFC PALLETEINDEX to QColor()
Hi guys,
I have to convert a PALLETEINDEX(int value) which returns COLORREF. Haveing the "value" I have to create a QCOlor object.
Can't find which PALLETEINDEX(value) return which color?
ANyone know how to create a QColor having PalleteIndex(value)(int MFC application)
Thanks
Re: MFC PALLETEINDEX to QColor()
MSDN:
Quote:
COLORREF value has the following hexadecimal form: 0x00bbggrr
To extract the individual values for the red, green, and blue components of a color value, use the GetRValue, GetGValue, and GetBValue macros, respectively.
Qt docs:
Quote:
typedef QRgb
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
They seem to be in a slightly different format so you can't pass COLORREF as QRgb, but something like this should do the trick:
Code:
COLORREF ref = PALETTEINDEX(n);
QColor color
= QColor::fromRgb(GetRValue
(ref
), GetGValue
(ref
), GetBValue
(ref
));
Re: MFC PALLETEINDEX to QColor()
Hi,
Thank you for the hint. My application is only using Qt libraries, but I also have an MFC application which I have to convert to Qt.
Howto get the COLOREF in Qt?
I need to find which color represents the PALLETEINDEX(int) in Qt.
ANy other ideas howto do this. I can't use COLORREF in Qt.
Thank you in advance.
Maverick
Re: MFC PALLETEINDEX to QColor()
Where does the palette index come from? Are you writing something portable?
Re: MFC PALLETEINDEX to QColor()
Hi,
Yes it is intended to be portable, there are some sets of colors and they have their RBG values. But the programmer who written the old application used some #define color1 int_value
and than create QPEN(...,...,...PALLETEINDEX(color1)); etc
Is it possible to use the "color1" and create a QColor from it ?
Maverick
Re: MFC PALLETEINDEX to QColor()
Start a new thread or read docs first.
Do not write non-related posts in this thread.
Thanks
Re: MFC PALLETEINDEX to QColor()
Quote:
Originally Posted by
maverick_pol
But the programmer who written the old application used some #define color1 int_value
and than create QPEN(...,...,...PALLETEINDEX(color1)); etc
Is it possible to use the "color1" and create a QColor from it ?
Try:
Re: MFC PALLETEINDEX to QColor()
Hi,
I will test the code today in the afternoon. Thank you for your advice. If anything come up(any errors) I will renew this thread.
Thanks