PDA

View Full Version : MFC PALLETEINDEX to QColor()



maverick_pol
20th September 2007, 09:19
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

jpn
20th September 2007, 09:33
MSDN:


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:


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:


COLORREF ref = PALETTEINDEX(n);
QColor color = QColor::fromRgb(GetRValue(ref), GetGValue(ref), GetBValue(ref));

maverick_pol
20th September 2007, 09:43
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

jpn
20th September 2007, 12:05
Where does the palette index come from? Are you writing something portable?

maverick_pol
20th September 2007, 14:37
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

Community_probs
20th September 2007, 14:59
can anybody tell me how to begin with QT Programmering.
I m new to this Technology.

maverick_pol
20th September 2007, 15:17
Start a new thread or read docs first.

Do not write non-related posts in this thread.

Thanks

jpn
20th September 2007, 16:25
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:


QColor color = QColormap::instance().colorAt(color1));

maverick_pol
24th September 2007, 07:10
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