本文整理汇总了C++中CColor::GetLuminance方法的典型用法代码示例。如果您正苦于以下问题:C++ CColor::GetLuminance方法的具体用法?C++ CColor::GetLuminance怎么用?C++ CColor::GetLuminance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CColor
的用法示例。
在下文中一共展示了CColor::GetLuminance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawVertical
///////////////////////////////////////////////////////////////////////////////
// DrawVertical
void CXScrollBar::DrawVertical()
{
TRACE(_T("in CXScrollBar::DrawVertical\n"));
CClientDC dc(this);
CMemDC memDC(&dc, &m_rectClient);
CBrush brushFrame(FRAME_COLOR);
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(&dc);
CBitmap bitmap;
// ===== draw Up arrow =====
VERIFY(bitmap.LoadBitmap(IDB_VERTICAL_SCROLLBAR_UPARROW));
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);
// NOTE: thumb and arrow bitmaps are assumed to be same width and height
CRect rectUpArrow(m_rectClient.left, m_rectClient.top,
m_rectClient.right, m_rectClient.top + m_nBitmapHeight);
memDC.StretchBlt(rectUpArrow.left, rectUpArrow.top,
rectUpArrow.Width(), rectUpArrow.Height(),
&bitmapDC, 0, 0, m_nBitmapWidth, m_nBitmapHeight, SRCCOPY);
memDC.FrameRect(&rectUpArrow, &brushFrame);
if (pOldBitmap)
{
bitmapDC.SelectObject(pOldBitmap);
}
if (bitmap.GetSafeHandle())
{
bitmap.DeleteObject();
}
pOldBitmap = NULL;
int nChannelStart = m_rectClient.top + m_nBitmapHeight;
int nChannelHeight = m_rectClient.Height() - 2*m_nBitmapHeight;
// ===== draw channel =====
// save new thumb position
TRACE(_T("m_nThumbTop=%d\n"), m_nThumbTop);
m_rectThumb.left = m_rectClient.left;
m_rectThumb.right = m_rectThumb.left + m_rectClient.Width();
m_rectThumb.top = m_rectClient.top + m_nThumbTop;
m_rectThumb.bottom = m_rectThumb.top + m_nBitmapHeight;
VERIFY(bitmap.LoadBitmap(IDB_VERTICAL_SCROLLBAR_CHANNEL));
pOldBitmap = bitmapDC.SelectObject(&bitmap);
CRect rectChannelDown(m_rectClient.left, m_rectThumb.top + m_nBitmapHeight/2,
m_rectClient.right, nChannelStart + nChannelHeight);
memDC.StretchBlt(rectChannelDown.left+1, rectChannelDown.top,
rectChannelDown.Width()-1, rectChannelDown.Height(),
&bitmapDC, 0, 0, m_nBitmapWidth, 1, SRCCOPY);
if (m_bChannelColor && m_bThumbColor)
{
// thumb has a color, so use same (lightened) color for channel
CColor color;
color.SetRGB(GetRValue(m_ThumbColor),
GetGValue(m_ThumbColor),
GetBValue(m_ThumbColor));
color.ToHLS();
float fLuminance = color.GetLuminance();
// use 80% L, 150% S for main color
fLuminance = .80f;
float fSaturation = color.GetSaturation();
fSaturation = 0.5f * fSaturation;
float fHue = color.GetHue();
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb3 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
// use .87 L for second highlight color
fLuminance = .87f;
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb2 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
// use .92 L for first highlight color
fLuminance = .92f;
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb1 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
BITMAP bm;
bitmap.GetBitmap(&bm);
// set highlight colors
bitmapDC.SetPixel(0, 0, rgb1);
bitmapDC.SetPixel(1, 0, rgb2);
//.........这里部分代码省略.........
示例2: MXP_OpenAtomicTag
//.........这里部分代码省略.........
// convert to RGB colour to start with in case only FORE or BACK supplied
pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom
pStyle->iFlags |= COLOUR_RGB;
// foreground colour
strArgument = GetArgument (ArgumentList, "fore", 1, true); // get foreground colour
if (!m_bIgnoreMXPcolourChanges)
if (SetColour (strArgument, pStyle->iForeColour))
MXP_error (DBG_ERROR, errMXP_UnknownColour,
TFormat ("Unknown colour: \"%s\"" ,
(LPCTSTR) strArgument));
// background colour
strArgument = GetArgument (ArgumentList, "back", 2, true); // get background colour
if (!m_bIgnoreMXPcolourChanges)
if (SetColour (strArgument, pStyle->iBackColour))
MXP_error (DBG_ERROR, errMXP_UnknownColour,
TFormat ("Unknown colour: \"%s\"" ,
(LPCTSTR) strArgument));
}
break; // end of COLOR
case MXP_ACTION_HIGH:
{
CColor clr;
pStyle->iForeColour = colour1;
pStyle->iBackColour = colour2;
// convert to RGB colour to start with
pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom
pStyle->iFlags |= COLOUR_RGB;
clr.SetColor (colour1);
float lum = clr.GetLuminance ();
lum += 0.15f;
if (lum > 1.0f)
lum = 1.0f;
clr.SetLuminance (lum);
pStyle->iForeColour = clr;
}
break; // end of COLOR
case MXP_ACTION_SEND:
// send to mud hyperlink
pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions
if (GetKeyword (ArgumentList, "prompt"))
pStyle->iFlags |= ACTION_PROMPT; // prompt action
else
pStyle->iFlags |= ACTION_SEND; // send-to action
if (m_bUnderlineHyperlinks)
pStyle->iFlags |= UNDERLINE; // underline it
if (m_bUseCustomLinkColour)
{
// find current background RGB value
pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour
pStyle->iBackColour = colour2;
pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom
pStyle->iFlags |= COLOUR_RGB;
}
strArgument = GetArgument (ArgumentList,"href", 1, false); // get link
if (strArgument.IsEmpty ())
示例3: DrawHorizontal
///////////////////////////////////////////////////////////////////////////////
// DrawHorizontal
void CXScrollBar::DrawHorizontal()
{
TRACE(_T("in CXScrollBar::DrawHorizontal\n"));
CClientDC dc(this);
CMemDC memDC(&dc, &m_rectClient);
CBrush brushFrame(FRAME_COLOR);
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(&dc);
CBitmap bitmap;
// ===== draw left arrow =====
VERIFY(bitmap.LoadBitmap(IDB_HORIZONTAL_SCROLLBAR_LEFTARROW));
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);
// NOTE: thumb and arrow bitmaps are assumed to be same width and height
CRect rectLeftArrow(m_rectClient.left, m_rectClient.top,
m_rectClient.left + m_nBitmapWidth, m_rectClient.bottom);
memDC.StretchBlt(rectLeftArrow.left, rectLeftArrow.top+1,
rectLeftArrow.Width(), rectLeftArrow.Height()-1,
&bitmapDC, 0, 0, m_nBitmapWidth, m_nBitmapHeight, SRCCOPY);
memDC.FrameRect(&rectLeftArrow, &brushFrame);
int nChannelStart = m_rectClient.left + m_nBitmapWidth;
int nChannelWidth = m_rectClient.Width() - 2*m_nBitmapWidth;
if (pOldBitmap)
{
bitmapDC.SelectObject(pOldBitmap);
}
if (bitmap.GetSafeHandle())
{
bitmap.DeleteObject();
}
pOldBitmap = NULL;
// ===== draw channel =====
// save new thumb position
TRACE(_T("m_nThumbLeft=%d\n"), m_nThumbLeft);
m_rectThumb.left = m_rectClient.left + m_nThumbLeft;
m_rectThumb.right = m_rectThumb.left + m_nBitmapWidth;
m_rectThumb.top = m_rectClient.top;
m_rectThumb.bottom = m_rectThumb.top + m_rectClient.Height();
VERIFY(bitmap.LoadBitmap(IDB_HORIZONTAL_SCROLLBAR_CHANNEL));
pOldBitmap = bitmapDC.SelectObject(&bitmap);
CRect rectChannelRight(m_rectThumb.left + m_nBitmapWidth/2, m_rectClient.top,
nChannelStart + nChannelWidth, m_rectClient.bottom);
memDC.StretchBlt(rectChannelRight.left, rectChannelRight.top+1,
rectChannelRight.Width(), rectChannelRight.Height()-1,
&bitmapDC, 0, 0, 1, m_nBitmapHeight, SRCCOPY);
if (m_bChannelColor && m_bThumbColor)
{
// thumb has a color, so use same (lightened) color for channel
CColor color;
color.SetRGB(GetRValue(m_ThumbColor),
GetGValue(m_ThumbColor),
GetBValue(m_ThumbColor));
color.ToHLS();
float fLuminance = color.GetLuminance();
// use 80% L, 150% S for main color
fLuminance = .80f;
float fSaturation = color.GetSaturation();
fSaturation = 0.5f * fSaturation;
float fHue = color.GetHue();
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb3 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
// use .87 L for second highlight color
fLuminance = .87f;
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb2 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
// use .92 L for first highlight color
fLuminance = .92f;
color.SetHLS(fHue, fLuminance, fSaturation);
color.ToRGB();
COLORREF rgb1 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
BITMAP bm;
bitmap.GetBitmap(&bm);
// set highlight colors
bitmapDC.SetPixel(0, 0, rgb1);
//.........这里部分代码省略.........