本文整理汇总了C++中GetBValue函数的典型用法代码示例。如果您正苦于以下问题:C++ GetBValue函数的具体用法?C++ GetBValue怎么用?C++ GetBValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetBValue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
std::cout<<"* ___ ____ _ _ _ _ "<<std::endl;
std::cout<<"* |__] | |\\ | \\/ "<<std::endl;
std::cout<<"* | |___ | \\| _/\\_ "<<std::endl;
std::cout<<"-----------------------------"<<std::endl;
std::cout<<"leetlights v0.1"<<std::endl;
CROCCAT_Talk roccat;
roccat.RestoreLEDRGB();
const int bins = 15;
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
const int miniScreenY = nScreenHeight/10;
const int miniScreenX = nScreenWidth/10;
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(hDesktopWnd);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, miniScreenX, miniScreenY);
SelectObject(hCaptureDC,hCaptureBitmap);
SetStretchBltMode(hCaptureDC,HALFTONE);
int histogram[bins+1][bins+1][bins+1];
COLORREF* pixel = new COLORREF [ miniScreenX * miniScreenY ];
int lR=0;
int lG=0;
int lB=0;
DWORD start = GetTickCount();
DWORD diff;
DWORD lastTime = start+1;
DWORD time;
while(true)
{
time = GetTickCount();
diff= start-time ;
lastTime = time ;
if(!StretchBlt(hCaptureDC,0,0,miniScreenX,miniScreenY,hDesktopDC,0,0,nScreenWidth,nScreenHeight,SRCCOPY))
{
std::cout<<"Capturing failed, skipping iteration"<<std::endl;
Sleep(100);
continue;
}
BITMAPINFO MyBMInfo = {0};
BITMAPINFO bmpInfo;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = miniScreenX;
bmpInfo.bmiHeader.biHeight = miniScreenY;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 32;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biClrUsed = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
if(0 == GetDIBits(hCaptureDC, hCaptureBitmap, 0,(UINT)miniScreenY, pixel, (BITMAPINFO *)&bmpInfo, DIB_RGB_COLORS))
{
std::cout<<"Receiving Data failed, skipping interation"<<std::endl;
Sleep(100);
continue;
}
int r,g,b;
int rB,gB,bB;
int max1 =0;
int maxR1=0;
int maxG1=0;
int maxB1=0;
int max2 =0;
int maxR2=0;
int maxG2=0;
int maxB2=0;
int max3 =0;
int maxR3=0;
int maxG3=0;
int maxB3=0;
int max4 =0;
int maxR4=0;
int maxG4=0;
int maxB4=0;
int lastColorIntensity =0;
memset(histogram,0,sizeof(histogram[0][0][0])*bins*bins*bins);
for (int i=0; i<miniScreenX*miniScreenY; i++)
{
r =GetBValue(pixel[i]);
g =GetGValue(pixel[i]);
b =GetRValue(pixel[i]);
rB = (int)(r/255.f*(bins));
gB = (int)(g/255.f*(bins));
bB = (int)(b/255.f*(bins));
histogram[rB][gB][bB] ++;
if(histogram[rB][gB][bB] >=max4)
//.........这里部分代码省略.........
开发者ID:newyork167,项目名称:leetlights,代码行数:101,代码来源:main.cpp
示例2: ShowMessage
//上传图片
void CDlgCustomFace::OnBnClickedUpload()
{
if ( m_Image.IsNull() )
{
ShowMessage(TEXT("请选择图片!"));
return ;
}
//设置状态
m_enOperateStatus = enOperateStatus_Upload;
//链接网络
if ( ConnectServer() == false )
{
//设置状态
m_enOperateStatus = enOperateStatus_NULL;
return;
}
//获取DC
CDC *pDC = GetDC();
LONG lBmpSize = LARGE_FACE_HEIGHT * (LARGE_FACE_WIDTH*3+LARGE_FACE_WIDTH%4) ;
BYTE *pByteBmpData = (BYTE *)VirtualAlloc(NULL,lBmpSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
//构造位图
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bfh.bfReserved1=0;
bfh.bfReserved2=0;
bfh.bfType = 0x4D42;
bfh.bfSize=lBmpSize+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER) ;
bih.biBitCount=24;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=BI_RGB;
bih.biHeight=LARGE_FACE_HEIGHT;
bih.biPlanes=1;
bih.biSize=sizeof(bih);
bih.biSizeImage=0;
bih.biWidth=LARGE_FACE_WIDTH;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
//设置像素
WORD wWidth = (LARGE_FACE_WIDTH*3+LARGE_FACE_WIDTH%4);
for ( int nCol = 0, nRealCol = LARGE_FACE_HEIGHT-1; nCol < LARGE_FACE_HEIGHT; ++nCol, --nRealCol )
for ( WORD wRow = 0, wByteIdex = 0; wRow < LARGE_FACE_WIDTH; wRow++, wByteIdex+=3)
{
COLORREF clr = pDC->GetPixel(LARGE_FRAME_LEFT+wRow, LARGE_FRAME_TOP+nCol);
pByteBmpData[nRealCol*wWidth+wByteIdex] = GetBValue(clr);
pByteBmpData[nRealCol*wWidth+wByteIdex+1] = GetGValue(clr);
pByteBmpData[nRealCol*wWidth+wByteIdex+2] = GetRValue(clr);
}
//创建目录
CString strDirName = CString(g_GlobalUnits.GetWorkDirectory()) + TEXT("\\CustomFace");
CreateDirectory(strDirName, NULL) ;
CString strFileName;
strFileName = TEXT("\\MyFace.bmp");
//写入文件
CFile fileMyFace;
try
{
if ( fileMyFace.Open(strDirName + strFileName, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary) )
{
//写入位图
fileMyFace.Write(&bfh, sizeof(bfh));
fileMyFace.Write(&bih, sizeof(bih));
fileMyFace.Write(pByteBmpData, lBmpSize);
//关闭文件
fileMyFace.Close();
}
//压缩文件
CZip oZip( strDirName + strFileName );
oZip.SwapSize( strDirName+TEXT("\\MyFace.zip") );
}
catch(...){}
//释放资源
ReleaseDC(pDC);
VirtualFree(pByteBmpData, lBmpSize , MEM_DECOMMIT) ;
//更新控件
UpdateControls();
}
开发者ID:vsanth,项目名称:kkj,代码行数:93,代码来源:DlgCustomFace.cpp
示例3: Log_CreateRtfHeader
char* Log_CreateRtfHeader(MODULEINFO *mi)
{
int i;
// guesstimate amount of memory for the RTF header
size_t bufferEnd = 0, bufferAlloced = 4096;
char *buffer = (char *)mir_realloc(mi->pszHeader, bufferAlloced);
buffer[0] = '\0';
// get the number of pixels per logical inch
HDC hdc = GetDC(NULL);
chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(NULL, hdc);
// ### RTF HEADER
// font table
Log_Append(buffer, bufferEnd, bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
for (i = 0; i < OPTIONS_FONTCOUNT; i++)
Log_Append(buffer, bufferEnd, bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, chatApi.aFonts[i].lf.lfCharSet, chatApi.aFonts[i].lf.lfFaceName);
// colour table
Log_Append(buffer, bufferEnd, bufferAlloced, "}{\\colortbl ;");
for (i = 0; i < OPTIONS_FONTCOUNT; i++)
Log_Append(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(chatApi.aFonts[i].color), GetGValue(chatApi.aFonts[i].color), GetBValue(chatApi.aFonts[i].color));
for (i = 0; i < mi->nColorCount; i++)
Log_Append(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
// new paragraph
Log_Append(buffer, bufferEnd, bufferAlloced, "}\\pard");
// set tabs and indents
int iIndent = 0;
if (g_Settings->dwIconFlags) {
iIndent += (14 * 1440) / chatApi.logPixelSX;
Log_Append(buffer, bufferEnd, bufferAlloced, "\\tx%u", iIndent);
}
if (g_Settings->bShowTime) {
int iSize = (g_Settings->LogTextIndent * 1440) / chatApi.logPixelSX;
Log_Append(buffer, bufferEnd, bufferAlloced, "\\tx%u", iIndent + iSize);
if (g_Settings->bLogIndentEnabled)
iIndent += iSize;
}
Log_Append(buffer, bufferEnd, bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
return buffer;
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:51,代码来源:chat_log.cpp
示例4: Assert
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pDC -
// bounds -
//-----------------------------------------------------------------------------
void Box3D::RenderTool2D(CRender2D *pRender)
{
Vector mins = bmins;
Vector maxs = bmaxs;
CMapView2D *pView = (CMapView2D*)pRender->GetView();
Assert( pRender );
if ( IsTranslating() )
{
TranslateBox( mins, maxs );
}
else if ( IsEmpty() )
{
return;
}
if ( m_dwDrawFlags & boundstext)
{
DrawBoundsText(pRender, mins, maxs, DBT_TOP | DBT_LEFT);
}
if ( IsTranslating() )
{
pRender->PushRenderMode( RENDER_MODE_DOTTED );
pRender->SetDrawColor( GetRValue(Options.colors.clrToolDrag), GetGValue(Options.colors.clrToolDrag), GetBValue(Options.colors.clrToolDrag) );
}
else if (!(m_dwDrawFlags & thicklines))
{
pRender->PushRenderMode( RENDER_MODE_DOTTED );
pRender->SetDrawColor( GetRValue(m_clrBox), GetGValue(m_clrBox), GetBValue(m_clrBox) );
}
else
{
pRender->PushRenderMode( RENDER_MODE_FLAT_NOZ );
pRender->SetDrawColor( GetRValue(m_clrBox), GetGValue(m_clrBox), GetBValue(m_clrBox) );
}
// render bounds
if ( !IsTranslating() || m_TranslateMode == modeScale || m_TranslateMode == modeMove )
{
// draw simple rectangle
pRender->DrawRectangle( mins, maxs, false, 0 );
}
else
{
// during rotation or shearing, draw transformed bounding box
Vector v[4];
// init all points to center
v[0] = v[1] = v[2] = v[3] = (bmins+bmaxs) / 2;
int axis = pView->axHorz;
v[0][axis] = v[1][axis] = bmins[axis];
v[2][axis] = v[3][axis] = bmaxs[axis];
axis = pView->axVert;
v[1][axis] = v[2][axis] = bmins[axis];
v[0][axis] = v[3][axis] = bmaxs[axis];
for ( int i=0; i<4; i++)
{
TranslatePoint( v[i] );
}
pRender->DrawLine( v[0], v[1] );
pRender->DrawLine( v[1], v[2] );
pRender->DrawLine( v[2], v[3] );
pRender->DrawLine( v[3], v[0] );
}
pRender->PopRenderMode();
// draw a cross for translation origin in move or rotation mode
if ( IsTranslating() )
{
if ( m_TranslateMode == modeMove || m_TranslateMode == modeRotate )
{
Vector vec = m_vTranslationFixPoint;
if ( m_TranslateMode == modeMove )
{
TranslatePoint( vec );
}
// draw 'X'
pRender->SetHandleStyle( 7, CRender::HANDLE_CROSS );
pRender->SetHandleColor( GetRValue(Options.colors.clrToolDrag), GetGValue(Options.colors.clrToolDrag), GetBValue(Options.colors.clrToolDrag) );
pRender->DrawHandle( vec );
}
//.........这里部分代码省略.........
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:box3d.cpp
示例5: GetNumTokens
void CPolyDlg::OnEnterKey( UINT ctlID )
{
CString csMsg, csEditstr, csItemNum, newitmstr ;
int itemnum ;
CComboBox& combo = m_Combo_Corner ; //convenience
//Get editbox string
CWnd* pWnd = (combo.GetWindow(GW_CHILD)) ;
CWnd* pEditWnd = (pWnd->GetNextWindow()); //pointer to editbox window
pEditWnd->GetWindowText( csEditstr );
csEditstr.TrimLeft() ; csEditstr.TrimRight() ;
int numtokens = GetNumTokens( csEditstr ) ;
int numitems = combo.GetCount() ;
//check for too few or too many tokens in the entry string
if( numtokens < 2 )
{
csMsg = "Each entry must have at least X & Y positions " ;
AfxMessageBox( csMsg + "\n" + csEditstr ) ;
return ;
}
else if( numtokens > 7 )
{
csMsg = "Each line can have no more than seven items" ;
AfxMessageBox( csMsg + "\n" + csEditstr ) ;
return ;
}
//OK, 2 or 3 tokens: get valid X/Y pos
Vector3D vcrnr = GetCnrVector( csEditstr ) ;
//3 tokens are considered to be [X Position] [Y Position] [Z Position]
if( numtokens == 3 )
{
//prepend item num & add to end
itemnum = numitems + 1 ;
FormatNumStr( csItemNum, itemnum ) ;
newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, 0, 0, 0 ) ;
csEditstr = csItemNum + newitmstr ;
combo.AddString( csEditstr ) ;
itemnum = GetItemNum( csEditstr ) ;
}
// 6 tokens are assumed to be [X Position] [Y Position] [Z Position] [R] [G] [B]
else if( numtokens == 6 )
{
COLORREF col = GetCnrColor( csEditstr ) ;
int R = GetRValue( col ) ;
int G = GetGValue( col ) ;
int B = GetBValue( col ) ;
//prepend item num & add to end
itemnum = numitems + 1 ;
FormatNumStr( csItemNum, itemnum ) ;
newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
csEditstr = csItemNum + newitmstr ;
combo.AddString( csEditstr ) ;
itemnum = GetItemNum( csEditstr ) ;
}
//otherwise we assume [Item #] [X Position] [Y Position] [Z Position] [R] [G] [B]
else
{
itemnum = GetItemNum( csEditstr ) ;
COLORREF col = GetCnrColor( csEditstr ) ;
int R = GetRValue( col ) ;
int G = GetGValue( col ) ;
int B = GetBValue( col ) ;
//insert at item number or add to end
if( itemnum > numitems )
{
//prepend correct item num & add to end
itemnum = numitems + 1 ;
FormatNumStr( csItemNum, itemnum ) ;
newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
csEditstr = csItemNum + newitmstr ;
combo.AddString( csEditstr ) ;
}
else if( itemnum < numitems )
{
combo.DeleteString( itemnum - 1 ) ;
FormatNumStr( csItemNum, itemnum ) ;
newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
csEditstr = csItemNum + newitmstr ;
combo.InsertString( itemnum - 1, csEditstr ) ;
}
else //itemnum points to last string
{
combo.DeleteString( itemnum - 1 ) ;
FormatNumStr( csItemNum, itemnum ) ;
newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
csEditstr = csItemNum + newitmstr ;
combo.AddString( csEditstr ) ;
}
}
//.........这里部分代码省略.........
开发者ID:pvaut,项目名称:Z-Flux,代码行数:101,代码来源:PolyDlg.cpp
示例6: RGBtoHSL
// This function extracts the hue, saturation, and luminance from "color"
// and places these values in h, s, and l respectively.
void RGBtoHSL(unsigned int color,unsigned int& h, unsigned int& s, unsigned int& l)
{
unsigned int r = (unsigned int)GetRValue(color);
unsigned int g = (unsigned int)GetGValue(color);
unsigned int b = (unsigned int)GetBValue(color);
float r_percent = ((float)r)/255;
float g_percent = ((float)g)/255;
float b_percent = ((float)b)/255;
float max_color = 0;
if((r_percent >= g_percent) && (r_percent >= b_percent))
{
max_color = r_percent;
}
if((g_percent >= r_percent) && (g_percent >= b_percent))
max_color = g_percent;
if((b_percent >= r_percent) && (b_percent >= g_percent))
max_color = b_percent;
float min_color = 0;
if((r_percent <= g_percent) && (r_percent <= b_percent))
min_color = r_percent;
if((g_percent <= r_percent) && (g_percent <= b_percent))
min_color = g_percent;
if((b_percent <= r_percent) && (b_percent <= g_percent))
min_color = b_percent;
float L = 0;
float S = 0;
float H = 0;
L = (max_color + min_color)/2;
if(max_color == min_color)
{
S = 0;
H = 0;
}
else
{
if(L < .50)
{
S = (max_color - min_color)/(max_color + min_color);
}
else
{
S = (max_color - min_color)/(2 - max_color - min_color);
}
if(max_color == r_percent)
{
H = (g_percent - b_percent)/(max_color - min_color);
}
if(max_color == g_percent)
{
H = 2 + (b_percent - r_percent)/(max_color - min_color);
}
if(max_color == b_percent)
{
H = 4 + (r_percent - g_percent)/(max_color - min_color);
}
}
s = (unsigned int)(S*100);
l = (unsigned int)(L*100);
H = H*60;
if(H < 0)
H += 360;
h = (unsigned int)H;
}
开发者ID:AnwarMohamed,项目名称:EmoAnalyzer,代码行数:71,代码来源:HSL2RGB.cpp
示例7: if
void CChangeBackgroudWnd::Notify(TNotifyUI& msg)
{
if (msg.sType == _T("click"))
{
if (msg.pSender == m_pOptSwitch)
{
if ( m_pOptSwitch->IsSelected())
{
m_pSlider->SetVisible(false);
}
else
{
m_pSlider->SetVisible(true);
}
}
if (msg.pSender == m_PaintManager.FindControl(_T("bnt_bgimage")))
{
m_pTab->SelectItem(0);
}
else if (msg.pSender == m_PaintManager.FindControl(_T("btn_color")))
{
m_pTab->SelectItem(1);
}
else if (_tcsstr(msg.pSender->GetName(), _T("colour_")) != 0)
{
CSliderUI* AdjustColorSliderR = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderRControlName));
CSliderUI* AdjustColorSliderG = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderGControlName));
CSliderUI* AdjustColorSliderB = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderBControlName));
if ((AdjustColorSliderR != NULL) && (AdjustColorSliderG != NULL) && (AdjustColorSliderB != NULL))
{
DWORD dwColor = msg.pSender->GetBkColor();
AdjustColorSliderR->SetValue(static_cast<BYTE>(GetRValue(dwColor)));
AdjustColorSliderG->SetValue(static_cast<BYTE>(GetGValue(dwColor)));
AdjustColorSliderB->SetValue(static_cast<BYTE>(GetBValue(dwColor)));
static_cast<CPlayerWnd*>(m_pParent)->SetBkColor(dwColor);
}
}
}
else if (msg.sType == _T("valuechanged"))
{
CSliderUI* AdjustColorSliderR = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderRControlName));
CSliderUI* AdjustColorSliderG = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderGControlName));
CSliderUI* AdjustColorSliderB = static_cast<CSliderUI*>(m_PaintManager.FindControl(kAdjustColorSliderBControlName));
if ((AdjustColorSliderR != NULL) && (AdjustColorSliderG != NULL) && (AdjustColorSliderB != NULL))
{
BYTE red = AdjustColorSliderR->GetValue();
BYTE green = AdjustColorSliderG->GetValue();
BYTE blue = AdjustColorSliderB->GetValue();
COLORREF crColor = RGB(red, green, blue);
TCHAR szBuf[MAX_PATH] = {0};
#if defined(UNDER_CE)
_stprintf(szBuf, _T("FF%02X%02X%02X"), GetRValue(crColor), GetGValue(crColor), GetBValue(crColor));
#else
_stprintf_s(szBuf, MAX_PATH - 1, _T("FF%02X%02X%02X"), GetRValue(crColor), GetGValue(crColor), GetBValue(crColor));
#endif
LPTSTR pstr = NULL;
DWORD dwColor = _tcstoul(szBuf, &pstr, 16);
m_pParent->SetBkColor(dwColor);
}
}
}
开发者ID:yuechuanbingzhi163,项目名称:Player,代码行数:63,代码来源:ChangeBgWnd.cpp
示例8: GetPos
//.........这里部分代码省略.........
clrRange clr;
clr = colorList[loop];
// Get the good values. If not set, then entire range is good
int lval = clr.lval;
int hval = clr.hval;
if((lval < min) || (lval > max)) lval = min;
if((hval > max) || (hval < min)) hval = max;
if(lval == min)
{
gotStartColor = TRUE;
startColor = clr.strColor;
}
if(hval == max)
{
gotEndColor = TRUE;
endColor = clr.endColor;
}
int minVal = lval - min; // offset into bitmap for this color
minVal = int(double(minVal)/scale);
// width (or height for vertical slider) inside bitmap for this color
int widthVal = hval - lval;
widthVal = int((double(widthVal)/scale) + 1.0);
// For drawing a gradient, we need to know the individual RGB values
int sR,eR,sG,eG,sB,eB; // start and end R, G, and B values
sR = GetRValue(clr.strColor);
eR = GetRValue(clr.endColor);
sG = GetGValue(clr.strColor);
eG = GetGValue(clr.endColor);
sB = GetBValue(clr.strColor);
eB = GetBValue(clr.endColor);
if(GradientFill != NULL)
{
TRIVERTEX vert[2]; // for specifying range to gradient fill
GRADIENT_RECT gRect;
// Warning C4244: conversion from 'int' to 'unsigned short', possible loss of data
#pragma warning (push)
#pragma warning (disable : 4244)
vert[0].Red = sR<<8; // expects 16-bit color values!
vert[0].Green = sG<<8;
vert[0].Blue = sB<<8;
vert[0].Alpha = 0; // no fading/transparency
vert[1].Red = eR<<8;
vert[1].Green = eG<<8;
vert[1].Blue = eB<<8;
vert[1].Alpha = 0;
#pragma warning (pop)
gRect.UpperLeft = 0;
gRect.LowerRight = 1;
BOOL retval;
if(IsVertical) // vertically oriented?
{
vert[0].x = 0;
vert[0].y = Offset + minVal;
vert[1].x = iWidth;
vert[1].y = Offset + minVal + widthVal;
retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V);
开发者ID:zekoman,项目名称:tibiaauto,代码行数:67,代码来源:SliderCtrlEx.cpp
示例9: memset
// draw the item
bool wxOwnerDrawn::OnDrawItem(
wxDC& rDC
, const wxRect& rRect
, wxODAction eAction
, wxODStatus eStatus
)
{
//
// We do nothing on focus change
//
if (eAction == wxODFocusChanged )
return TRUE;
//
// Select the font and draw the text
// ---------------------------------
//
CHARBUNDLE vCbnd;
HPS hPS= rDC.GetHPS();
wxColour vColBack;
wxColour vColText;
COLORREF vRef;
RECTL vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};
memset(&vCbnd, 0, sizeof(CHARBUNDLE));
//
// Use default font if no font set
//
if (m_font.Ok())
{
m_font.RealizeResource();
}
else
{
::GpiSetCharSet(hPS, LCID_DEFAULT);
}
//
// Based on the status of the menu item, pick the right colors
//
if (eStatus & wxODSelected)
{
wxColour vCol2(wxT("WHITE"));
vColBack.Set( (unsigned char)0
,(unsigned char)0
,(unsigned char)160
); // no dark blue in color table
vColText = vCol2;
}
else if (eStatus & wxODDisabled)
{
vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENU // Light gray
,0L
);
vColBack.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENUDISABLEDTEXT // dark gray
,0L
);
vColText.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
}
else
{
//
// Fall back to default colors if none explicitly specified
//
vRef = ::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENU // we are using gray for all our window backgrounds in wxWidgets
,0L
);
vColBack.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
vRef = ::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_WINDOWTEXT // Black
,0L
);
vColText.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
}
rDC.SetTextBackground(vColBack);
rDC.SetTextForeground(vColText);
rDC.SetBackgroundMode(wxTRANSPARENT);
vCbnd.lColor = vColText.GetPixel();
vCbnd.lBackColor = vColBack.GetPixel();
::GpiSetAttrs( hPS
//.........这里部分代码省略.........
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,代码来源:ownerdrw.cpp
示例10: GetSysColor
Color RenderThemeWinCE::platformInactiveSelectionBackgroundColor() const
{
COLORREF color = GetSysColor(COLOR_GRAYTEXT);
return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
}
开发者ID:13W,项目名称:phantomjs,代码行数:5,代码来源:RenderThemeWinCE.cpp
示例11: GetLowColor
// Draw the tiles
//
void CTileCastleFlag::Draw( CDC* pDC, int x, int y, int x2, int x3, int y2, int y3, int y4, int DrawingLevel)
{
// Compute polyline around tiles
POINT Points1[4];
int NbPoint1 = 4;
int TilePos = 0;
double LowColor = GetLowColor( DrawingLevel );
Points1[0].x=x+x2;
Points1[0].y=y-y2;
Points1[1].x=x+x3;
Points1[1].y=y;
Points1[2].x=(int) (x+x3-x2/4.0);
Points1[2].y=(int) (y+y2/4.0);
Points1[3].x=x+x2;
Points1[3].y=(int) (y-y2/2.0);
double cosa;
double sina;
switch( m_CurrentRotation )
{
case 0:
break;
case 1:
cosa = cos(60/180.0*PI);
sina = sin(60/180.0*PI);
break;
case 2:
cosa = cos(120/180.0*PI);
sina = sin(120/180.0*PI);
break;
case 3:
cosa = cos(180/180.0*PI);
sina = sin(180/180.0*PI);
break;
case 4:
cosa = cos(240/180.0*PI);
sina = sin(240/180.0*PI);
break;
case 5:
cosa = cos(300/180.0*PI);
sina = sin(300/180.0*PI);
break;
}
if( m_CurrentRotation!=0 )
{
for( int i=0; i<NbPoint1; i++ )
{
double x1,y1;
x1 = cosa*(Points1[i].x-x-x2)-sina*(Points1[i].y-y-(y3-y2)/2.0);
y1 = sina*(Points1[i].x-x-x2)+cosa*(Points1[i].y-y-(y3-y2)/2.0);
Points1[i].x = (int) (x+x2+x1);
Points1[i].y = (int) (y+(y3-y2)/2.0+y1);
}
}
CPen Pen;
Pen.CreatePen(PS_NULL,0,RGB(0,0,0));
CPen* pOldPen = pDC->SelectObject( &Pen );
CBrush Brush;
if( m_IsSelected )
Brush.CreateSolidBrush( RGB(255,255*LowColor,255*LowColor) );
else
Brush.CreateSolidBrush( RGB(min(255,GetRValue(m_TileColor)+(255-GetRValue(m_TileColor))*LowColor),min(255,GetGValue(m_TileColor)+(255-GetGValue(m_TileColor))*LowColor),min(255,GetBValue(m_TileColor)+(255-GetBValue(m_TileColor))*LowColor)) );
CBrush* pOldBrush = pDC->SelectObject( &Brush );
pDC->Polygon( Points1, NbPoint1 );
// Draw points
CBrush BlackBrush;
BlackBrush.CreateSolidBrush( RGB(min(255,255*LowColor),min(255,255*LowColor),min(255,255*LowColor)) );
pDC->SelectObject( &BlackBrush );
double xe1 = (Points1[3].x+Points1[0].x)*.5;
double ye1 = (Points1[3].y+Points1[0].y)*.5;
double xe2 = (Points1[2].x+Points1[1].x)*.5;
double ye2 = (Points1[2].y+Points1[1].y)*.5;
int xe3 = (int) ((xe1+xe2)*.5);
int ye3 = (int) ((ye1+ye2)*.5);
int diameter = (int) (x2/10.0);
pDC->Ellipse( xe3-diameter, ye3-diameter, xe3+diameter, ye3+diameter );
pDC->SelectObject( pOldBrush );
pDC->SelectObject( pOldPen );
DrawExtend( pDC, x, y, x2, x3, y2, y3, y4, DrawingLevel);
}
开发者ID:dkniffin,项目名称:virtualscape,代码行数:94,代码来源:TileCastleFlag.cpp
示例12: glEnable
void Renderer::drawCovers(bool showTarget){
#ifdef COVER_ALPHA
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0.1f);
#endif
if (cfgHighlightWidth == 0)
showTarget = false;
if (appInstance->albumCollection->getCount() == 0)
return;
float centerOffset = displayPos->getCenteredOffset();
CollectionPos centerCover = displayPos->getCenteredPos();
CollectionPos firstCover = displayPos->getOffsetPos(coverPos.getFirstCover() + 1);
CollectionPos lastCover = displayPos->getOffsetPos(coverPos.getLastCover());
lastCover++; // getOffsetPos does not return the end() element
CollectionPos targetCover = appInstance->albumCollection->getTargetPos();
int offset = appInstance->albumCollection->rank(firstCover) - appInstance->albumCollection->rank(centerCover);
for (CollectionPos p = firstCover; p != lastCover; ++p, ++offset){
float co = -centerOffset + offset;
shared_ptr<ImgTexture> tex = texLoader->getLoadedImgTexture(p);
tex->glBind();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// calculate darkening
float g = 1-(min(1.0f,(abs(co)-2)/5))*0.5f;
if (abs(co) < 2)
g = 1;
/*float g = 1 - (abs(co)-2)*0.2f;
g = 1 - abs(co)*0.1f;
g = 1 - abs(zRot)/80;
g= 1;
if (g < 0) g = 0;*/
glColor3f( g, g, g);
glVectord origin(0, 0.5, 0);
glQuad coverQuad = coverPos.getCoverQuad(co, tex->getAspect());
glPushName(SELECTION_CENTER + offset);
glBegin(GL_QUADS);
if (glFogCoordf) glFogCoordf((GLfloat)coverPos.distanceToMirror(coverQuad.topLeft));
glTexCoord2f(0.0f, 1.0f); // top left
glVertex3fv((GLfloat*)&(coverQuad.topLeft.x));
if (glFogCoordf) glFogCoordf((GLfloat)coverPos.distanceToMirror(coverQuad.topRight));
glTexCoord2f(1.0f, 1.0f); // top right
glVertex3fv((GLfloat*)&(coverQuad.topRight.x));
if (glFogCoordf) glFogCoordf((GLfloat)coverPos.distanceToMirror(coverQuad.bottomRight));
glTexCoord2f(1.0f, 0.0f); // bottom right
glVertex3fv((GLfloat*)&(coverQuad.bottomRight.x));
if (glFogCoordf) glFogCoordf((GLfloat)coverPos.distanceToMirror(coverQuad.bottomLeft));
glTexCoord2f(0.0f, 0.0f); // bottom left
glVertex3fv((GLfloat*)&(coverQuad.bottomLeft.x));
glEnd();
glPopName();
if (showTarget){
if (p == targetCover){
bool clipPlane = false;
if (glIsEnabled(GL_CLIP_PLANE0)){
glDisable(GL_CLIP_PLANE0);
clipPlane = true;
}
showTarget = false;
glColor3f(GetRValue(cfgTitleColor) / 255.0f, GetGValue(cfgTitleColor) / 255.0f, GetBValue(cfgTitleColor) / 255.0f);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glDisable(GL_TEXTURE_2D);
glLineWidth((GLfloat)cfgHighlightWidth);
glPolygonOffset(-1.0f, -1.0f);
glEnable(GL_POLYGON_OFFSET_LINE);
glEnable(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, (void*) &coverQuad);
glDrawArrays(GL_QUADS, 0, 4);
glDisable(GL_POLYGON_OFFSET_LINE);
glEnable(GL_TEXTURE_2D);
if (clipPlane)
glEnable(GL_CLIP_PLANE0);
}
}
}
#ifdef COVER_ALPHA
//.........这里部分代码省略.........
开发者ID:qq2377654,项目名称:foo_chronflow,代码行数:101,代码来源:Renderer.cpp
示例13: glClearColor
void Renderer::drawBg(){
glClearColor(GetRValue(cfgPanelBg)/255.0f, GetGValue(cfgPanelBg)/255.0f, GetBValue(cfgPanelBg)/255.0f, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
开发者ID:qq2377654,项目名称:foo_chronflow,代码行数:4,代码来源:Renderer.cpp
示例14: GetSubItemRect
//***************************************************************
void CMyColorList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (!lpDrawItemStruct) return;
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
int m=GetHeaderCtrl()->GetItemCount();
for(int i=0;i<m;i++)
{
CString str;
CRect rcItem;
GetSubItemRect(lpDrawItemStruct->itemID,i,LVIR_LABEL,rcItem);
str=GetItemText(lpDrawItemStruct->itemID,i);
CMyColor *col=(CMyColor *)m_ArrayCol.GetAt(lpDrawItemStruct->itemID);
pDC->SetBkMode(TRANSPARENT);
CBrush brush;
brush.CreateSolidBrush(col->colBack);
pDC->FillRect(rcItem,&brush);
pDC->SetTextColor(col->colText);
LV_ITEM lvi;
lvi.mask = LVIF_IMAGE | LVIF_STATE;
lvi.iItem = lpDrawItemStruct->itemID;
lvi.iSubItem = 0;
lvi.stateMask = 0xFFFF; // get all state flags
GetItem(&lvi);
if((lvi.state & LVIS_SELECTED)||(lvi.state & LVIS_FOCUSED))
{
if(m_blnSelect)
{
int r1=GetRValue(col->colSelect);
int g1=GetGValue(col->colSelect);
int b1=GetBValue(col->colSelect);
for(int i=rcItem.Height()/2;i>0;i--)
{
r1=(r1+5)>255?255:(r1+5);
g1=(g1+5)>255?255:(g1+5);
b1=(b1+5)>255?255:(b1+5);
CPen pen(PS_SOLID, 1, RGB(r1, g1, b1));
CPen *old = pDC->SelectObject(&pen);
pDC->MoveTo(rcItem.left,rcItem.top+i);
pDC->LineTo(rcItem.right,rcItem.top+i);
pDC->MoveTo(rcItem.left,rcItem.bottom-i);
pDC->LineTo(rcItem.right,rcItem.bottom-i);
pDC->SelectObject(old);
}
}
}
int nAlign=atoi(m_ArrayHeaderAlign.GetAt(i));
if(i==0&&GetImageList(LVSIL_SMALL)!=NULL)
{
CPoint ptImage;
ptImage.x=rcItem.left;
ptImage.y=rcItem.top;
GetImageList(LVSIL_SMALL)->Draw(pDC,lvi.iImage,ptImage,ILD_TRANSPARENT);
pDC->SetBkMode(TRANSPARENT);
rcItem.left=rcItem.left+16;
if(nAlign==LVCFMT_LEFT)
rcItem.left=rcItem.left+8;
}
switch(nAlign)
{
case LVCFMT_LEFT:
pDC->DrawText(str,rcItem,DT_LEFT);
break;
case LVCFMT_CENTER:
pDC->DrawText(str,rcItem,DT_CENTER);
break;
case LVCFMT_RIGHT:
pDC->DrawText(str,rcItem,DT_RIGHT);
break;
default:
pDC->DrawText(str,rcItem,DT_CENTER);
break;
}
}
}
开发者ID:likebeta,项目名称:code-snippets,代码行数:77,代码来源:MyColorList.cpp
示例15: OleTranslateColor
/******************************************************************************
* OleTranslateColor [OLEAUT32.421]
*
* Convert an OLE_COLOR to a COLORREF.
*
* PARAMS
* clr [I] Color to convert
* hpal [I] Handle to a palette for the conversion
* pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok
*
* RETURNS
* Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL.
* Failure: E_INVALIDARG, if any argument is invalid.
*
* FIXME
* Document the conversion rules.
*/
HRESULT WINAPI OleTranslateColor(
OLE_COLOR clr,
HPALETTE hpal,
COLORREF* pColorRef)
{
COLORREF colorref;
BYTE b = HIBYTE(HIWORD(clr));
TRACE("(%08lx, %p, %p)\n", clr, hpal, pColorRef);
/*
* In case pColorRef is NULL, provide our own to simplify the code.
*/
if (pColorRef == NULL)
pColorRef = &colorref;
switch (b)
{
case 0x00:
{
if (hpal != 0)
*pColorRef = PALETTERGB(GetRValue(clr),
GetGValue(clr),
GetBValue(clr));
else
*pColorRef = clr;
break;
}
case 0x01:
{
if (hpal != 0)
{
PALETTEENTRY pe;
/*
* Validate the palette index.
*/
if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0)
return E_INVALIDARG;
}
*pColorRef = clr;
break;
}
case 0x02:
*pColorRef = clr;
break;
case 0x80:
{
int index = LOBYTE(LOWORD(clr));
/*
* Validate GetSysColor index.
*/
if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR))
return E_INVALIDARG;
*pColorRef = GetSysColor(index);
break;
}
default:
return E_INVALIDARG;
}
return S_OK;
}
开发者ID:howard5888,项目名称:wineT,代码行数:89,代码来源:oleaut.c
示例16: GetClientRect
void COptionTreeItemColor::DrawControl(CDC *pDC, const RECT &rcRect)
{
// Declare variables
HGDIOBJ hOld;
HGDIOBJ hOldBrush;
COLORREF crOld;
int nOldBack;
CRect rcText, rcColor, rcClient;
CString strText;
CBrush bBrush;
COLORREF crOldBack;
// Get window rect
GetClientRect(rcClient);
// Select font
hOld = pDC->SelectObject(m_otOption->GetNormalFont());
// Create bush
bBrush.CreateSolidBrush(m_crColor);
// Set text color
if (IsReadOnly() == TRUE || m_otOption->IsWindowEnabled() == FALSE)
{
crOld = pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
}
else
{
crOld = pDC->SetTextColor(GetTextColor());
}
// Set background color
crOldBack = pDC->SetBkColor(GetBackgroundColor());
// Set background mode
nOldBack = pDC->SetBkMode(TRANSPARENT);
// Select brush
hOldBrush = pDC->SelectObject(GetSysColorBrush(COLOR_BTNSHADOW));
// Get color rectangle
rcColor.left = rcRect.left + 1;
rcColor.right = rcColor.left + (long) OT_COLOR_SIZE;
rcColor.top = rcRect.top + OT_SPACE - 2;
rcColor.bottom = rcColor.top + (long) OT_COLOR_SIZE;
// Draw color border
rcColor.InflateRect(1, 1, 1, 1);
pDC->PatBlt(rcColor.left, rcColor.top, rcColor.Width(), rcColor.Height(), PATCOPY);
// Draw color
rcColor.DeflateRect(1, 1, 1, 1);
pDC->FillRect(rcColor, &bBrush);
// Get text rectangle
rcText.left = rcColor.right + OT_SPACE;
rcText.right = rcRect.right;
rcText.top = rcRect.top;
rcText.bottom = rcRect.bottom;
// Get text
if (GetOption(OT_COLOR_SHOWHEX) == TRUE)
{
strText.Format(_T("#%.6X"), m_crColor);
}
else
{
strText.Format(_T("RGB (%d, %d, %d)"), GetRValue(m_crColor), GetGValue(m_crColor), GetBValue(m_crColor));
}
// Draw text
pDC->DrawText(strText, rcText, DT_SINGLELINE | DT_VCENTER);
pDC->DrawText(strText, rcText, DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
// Delete brush
if (bBrush.GetSafeHandle() != NULL)
{
bBrush.DeleteObject();
}
// Restore GDI ojects
pDC->SelectObject(hOldBrush);
pDC->SelectObject(hOld);
pDC->SetTextColor(crOld);
pDC->SetBkMode(nOldBack);
pDC->SetBkColor(crOldBack);
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:87,代码来源:OptionTreeItemColor.cpp
示例17: winToggleGetBgColorAttrib
static char* winToggleGetBgColorAttrib(Ihandle* ih)
{
/* the most important use of this is to provide
the correct background for images */
if (iupwin_comctl32ver6 && ih->data->type==IUP_TOGGLE_IMAGE)
{
COLORREF cr;
if (iupwinDrawGetThemeButtonBgColor(ih->handle, &cr))
return iupStrReturnStrf("%d %d %d", (int)GetRValue(cr), (int)GetGValue(cr), (int)GetBValue(cr));
}
if (ih->data->type == IUP_TOGGLE_TEXT)
return iupBaseNativeParentGetBgColorAttrib(ih);
else
return IupGetGlobal("DLGBGCOLOR");
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:16,代码来源:iupwin_toggle.c
示例18: wxColour
//--------------------------------------------------------------------------
// void wxPLDevDC::PutPixel( short x, short y, PLINT color )
//
// Draw a pixel in color color @ (x,y).
//--------------------------------------------------------------------------
void wxPLDevDC::PutPixel( short x, short y, PLINT color )
{
const wxPen oldpen = m_dc->GetPen();
m_dc->SetPen( *( wxThePenList->FindOrCreatePen( wxColour( GetRValue( color ), GetGValue( color ), GetBValue( color ) ),
1, wxSOLID ) ) );
m_dc->DrawPoint( x, y );
AddtoClipRegion( x, y, x, y );
m_dc->SetPen( oldpen );
}
开发者ID:FreeScienceCommunity,项目名称:PLPlot,代码行数:14,代码来源:deprecated_wxwidgets_dc.cpp
示例19: GetRValue
void CProgressCtrlX::DrawGradient(const CDrawInfo& info, const CRect &rcGrad, const CRect &rcClip, COLORREF clrStart, COLORREF clrEnd)
{
// Split colors to RGB chanels, find chanel with maximum difference
// between the start and end colors. This distance will determine
// number of steps of gradient
int r = (GetRValue(clrEnd) - GetRValue(clrStart));
int g = (GetGValue(clrEnd) - GetGValue(clrStart));
int b = (GetBValue(clrEnd) - GetBValue(clrStart));
int nSteps = max(abs(r), max(abs(g), abs(b)));
// if number of pixels in gradient less than number of steps -
// use it as numberof steps
int nPixels = rcGrad.Width();
nSteps = min(nPixels, nSteps);
if(nSteps == 0) nSteps = 1;
float rStep = (float)r/nSteps;
float gStep = (float)g/nSteps;
float bStep = (float)b/nSteps;
r = GetRValue(clrStart);
g = GetGValue(clrStart);
b = GetBValue(clrStart);
BOOL fLowColor = info.pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE;
if(!fLowColor && nSteps > 1)
if(info.pDC->GetDeviceCaps(BITSPIXEL)*info.pDC->GetDeviceCaps(PLANES) < 8)
nSteps = 1; // for 16 colors no gradient
float nWidthPerStep = (float)rcGrad.Width() / nSteps;
CRect rcFill(rcGrad);
CBrush br;
// Start filling
for (int i = 0; i < nSteps; i++)
{
rcFill.left = rcGrad.left + (int)(nWidthPerStep * i);
rcFill.right = rcGrad.left + (int)(nWidthPerStep * (i+1));
if(i == nSteps-1) //last step (because of problems with float)
rcFill.right = rcGrad.right;
if(rcFill.right < rcClip.left)
continue; // skip - band before cliping rect
// clip it
if(rcFill.left < rcClip.left)
rcFill.left = rcClip.left;
if(rcFi
|
请发表评论