本文整理汇总了C++中GetPixel函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPixel函数的具体用法?C++ GetPixel怎么用?C++ GetPixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPixel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Image
Image* Image::Crop(int x, int y, int w, int h)
{
/* Your Work Here (section 3.2.5) */
//return NULL ;
Pixel px;
Image* img = new Image(w, h);
for(int y_ = 0; y_ < h; y_++) {
for(int x_ = 0; x_ < w; x_++) {
px = GetPixel(x + x_, y + y_);
img->GetPixel(x_, y_).Set(px.r, px.g, px.b, px.a);
}
}
return img;
}
开发者ID:aqchin,项目名称:imagesignal,代码行数:15,代码来源:image.cpp
示例2: dc
void CMainDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
//dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();
RECT rect;
GetClientRect(&rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
COLORREF colortrans = RGB(0,255,0);
HBRUSH hBrush = CreateSolidBrush(colortrans);
FillRect(dc,&rect,hBrush);
DeleteObject(hBrush);
BITMAP bmp;
GetObject(m_hBmp,sizeof(bmp),&bmp);
HDC hBmpDC = CreateCompatibleDC(dc);
SelectObject(hBmpDC,m_hBmp);
TransparentBlt(dc,0,0,bmp.bmWidth, bmp.bmHeight,hBmpDC,0,0,bmp.bmWidth,bmp.bmHeight,RGB(0,255,0));
DeleteDC(hBmpDC);
if(m_bFirst){
HRGN rgn = GetTrans(dc,GetPixel(dc,0,0),0,0,bmp.bmWidth, bmp.bmHeight);
::SetWindowRgn(m_hWnd,rgn,TRUE);
m_bFirst = FALSE;
}
}
}
开发者ID:araneta,项目名称:NetTalk2,代码行数:48,代码来源:MainDlg.cpp
示例3: CheckHit
/*
* calculate where on the target the bolt hit
* this is based on the colours of the target rings
*/
static void CheckHit( HDC hdc, POINT hit_point )
/**********************************************/
{
DWORD colour;
unsigned short points;
unsigned short dialog_item;
BOOL translated;
colour = GetPixel( hdc, hit_point.x, hit_point.y );
switch( colour ) {
case RING1:
dialog_item = YELLOW;
break;
case RING2:
dialog_item = RED;
break;
case RING3:
dialog_item = BLUE;
break;
case RING4:
dialog_item = BLACK;
break;
case RING5:
dialog_item = WHITE;
break;
case BACKGROUND:
dialog_item = MISSED;
break;
}
/*
* increment # of hits on location
*/
points = GetDlgItemInt( ScoreWnd, dialog_item, &translated, FALSE );
points++;
SetDlgItemInt( ScoreWnd, dialog_item, points, FALSE );
/*
* increment # of shots
*/
points = GetDlgItemInt( ScoreWnd, SHOTS, &translated, FALSE );
points++;
SetDlgItemInt( ScoreWnd, SHOTS, points, FALSE );
return;
} /* CheckHit */
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:52,代码来源:shootgal.c
示例4: GetWidth
bool CFloodFill2::DrawLineH(int x1, int x2, int y, COLORREF Color, const CRect& Rect)
{
if (!m_pDib)
return false;
if (!m_bRedEye && Color == CLR_NONE)
return false;
if (x1 > x2)
x1^=x2, x2^=x1, x1^=x2;
if (x1 < 0 && x2 < 0)
return false;
LONG nWidth = GetWidth();
if (x1 >= nWidth && x2 >= nWidth)
return false;
if (x1 < 0)
x1 = 0;
if (x2 >= nWidth)
x2 = nWidth - 1;
int x = x1;
LPBYTE pPixel = DibPtrXYExact(m_pDib, x1, y);
LPBYTE pEnd = DibPtrXYExact(m_pDib, x2, y);
while (pPixel <= pEnd)
{
if (m_pBufferDib)
{
if (!m_bRedEye)
Color = m_pBufferDib->GetPixel(x++, y);
else
{
Color = GetPixel(x++, y);
RedEyeRemove(Color);
}
}
*pPixel++ = GetBValue(Color);
*pPixel++ = GetGValue(Color);
*pPixel++ = GetRValue(Color);
}
return true;
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:48,代码来源:FloodFill2.bak.cpp
示例5: update
void ImageWidget::mouseReleaseEvent(QMouseEvent *event)
{
QWidget::mouseReleaseEvent(event);
// Eventlogik
if (event->button() == Qt::LeftButton) {
mDraw = false;
// Aktualisiere Bild
update();
if (mTrack) {
emit ColorChanged(GetPixel());
}
}
}
开发者ID:LariscusObscurus,项目名称:ITP3_ImageProcessing,代码行数:16,代码来源:imagewidget.cpp
示例6: PrintState
static void PrintState(boolean *state) {
int x, y;
for (y = 0; y < STATE_HEIGHT; y++) {
printf(" ");
for (x = 0; x < STATE_WIDTH; x++) {
printf(GetPixel(state, x, y) ? "X" : "O");
printf(x != STATE_WIDTH - 1 ? "," : "");
printf((x + 1) % 5 == 0 ? " " : "");
}
printf("\n");
printf((y + 1) % 5 == 0 ? "\n" : "");
}
}
开发者ID:minlexx,项目名称:recordmydesktop-pulse,代码行数:16,代码来源:test-rectinsert.c
示例7: GetBlock
void CSampleView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (!m_iSize)
return;
if (point.y > m_clientRect.bottom)
return;
int Block = GetBlock(point.x);
m_iSelStart = GetPixel(Block);
m_iSelEnd = m_iSelStart;
Invalidate();
RedrawWindow();
m_bClicked = true;
CStatic::OnLButtonDown(nFlags, point);
}
开发者ID:ayushym,项目名称:nesicide,代码行数:16,代码来源:SampleEditorDlg.cpp
示例8: GetTextRect
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void ContextItem::Paint(HDC hDC)
{
if (m_ItemID == MENUITEM_ID_FOLDER)
FolderItem::Paint(hDC);
else
MenuItem::Paint(hDC);
if (0==(m_type & MFT_OWNERDRAW))
return;
RECT r; GetTextRect(&r);
int w = r.right - r.left;
int h = r.bottom - r.top;
// the remaining margin
int m = (int)imax(0, w - (m_bmp_width - m_icon_offset));
// text width
int tw = w - m;
HDC buf = CreateCompatibleDC(NULL);
HGDIOBJ other_bmp = SelectObject(buf, m_bmp);
#if 0
BitBlt(hDC, r.left, r.top, tw, h, buf, m_icon_offset, 0, SRCCOPY);
#else
// adjust offset according to justifications
if (mStyle.MenuFrame.Justify == DT_CENTER)
m /= 2;
else
if (mStyle.MenuFrame.Justify != DT_RIGHT)
m = 0;
// then plot points when they seem to have the textcolor
// icons on the left are cut off
COLORREF CRTXT_BB = m_bActive ? mStyle.MenuHilite.TextColor : mStyle.MenuFrame.TextColor;
int x, y;
for (y = 0; y < h; y++)
for (x = 0; x < tw; x++)
if (CRTXT_WIN == GetPixel(buf, x+m_icon_offset, y))
SetPixel (hDC, r.left+m+x, r.top+y, CRTXT_BB);
#endif
SelectObject(buf, other_bmp);
// this let's the handler know which command to invoke eventually
if (m_bActive) DrawItem(buf, m_bmp_width, h, true);
DeleteDC(buf);
}
开发者ID:fin-alice,项目名称:bb4nt,代码行数:48,代码来源:Contextmenu.cpp
示例9: SelectObject
ChessView::ChessView( HWND parent, Contact::ref contact )
{ _HWND=parent;
filePathCHESS=appRootPath+L"\\games\\chess\\chess_1.png";
bmpc=SHLoadImageFile(filePathCHESS.c_str());
/*GetObject(bmpc, sizeof(bmc), &bmc);*/
HDC hdcImage2=CreateCompatibleDC(NULL);
SelectObject(hdcSKIN, bmpc);
SelectObject(hdcImage2, bmpc);
flagaktiv=0;
transparentColorCH=GetPixel(hdcImage2, 0, 0);DeleteDC(hdcImage2);
int Chesspoleinit[9][9]={
0 , 0, 0, 0, 0, 0, 0, 0, 0,
0 ,12,13,14,15,16,14,13,12,
0 ,11,11,11,11,11,11,11,11,
0 , 0, 0, 0, 0, 0, 0, 0, 0,
0 , 0, 0, 0, 0, 0, 0, 0, 0,
0 , 0, 0, 0, 0, 0, 0, 0, 0,
0 , 0, 0, 0, 0, 0, 0, 0, 0,
0 , 1, 1, 1, 1, 1, 1, 1, 1,
0 , 2, 3, 4, 5, 6, 4, 3, 2
};
int cvtp=1;
for(int x=1;x<=8;x++){for(int y=1;y<=8;y++){
Chesspole[y][x]=Chesspoleinit[y][x];
}}
BOOST_ASSERT(parent);
if (windowClass==0)
windowClass=RegisterWindowClass();
if (windowClass==0) throw std::exception("Can't create window class");
parentHWnd=parent;
this->contact=contact;
thisHWnd=CreateWindow((LPCTSTR)windowClass, _T("chat"), WS_CHILD |WS_VISIBLE,
0, 0,
CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, g_hInst, (LPVOID)this);
}
开发者ID:m8r-ds1twq,项目名称:bombusng-qd,代码行数:47,代码来源:ChessView.cpp
示例10: OnTimer
VOID OnTimer(HWND hWindow, UINT uID)
{
POINT point = {};
static COLORREF previousColor = 0;
// Получение позиции курсора в экранных координатах.
GetCursorPos(&point);
// Получение контекста устройства для всего экрана.
HDC hDesktopDC = GetDC(NULL);
// Получение цвета пикселя под курсором.
g_currentColor = GetPixel(hDesktopDC, point.x, point.y);
// Освобождение контекста устройства.
ReleaseDC(NULL, hDesktopDC);
// Проверка, отличается ли цвет текущего пикселя от цвета предыдущего.
if (g_currentColor != previousColor)
{
// Формирование строки для последующего вывода на экран.
_stprintf_s(g_szText, TEXT("\n R: %d\n G: %d\n B: %d\n\n #%.2X%.2X%.2X"),
GetRValue(g_currentColor), GetGValue(g_currentColor), GetBValue(g_currentColor),
GetRValue(g_currentColor), GetGValue(g_currentColor), GetBValue(g_currentColor));
// Заполнение белым цветом растрового изображения, выбранного в контекст памяти.
PatBlt(g_hMemoryDC, 0, 0, g_clientRectangle.right, g_clientRectangle.bottom, WHITENESS);
// Установка цвета кисти, выбранной в контекст устройства.
SetDCBrushColor(g_hMemoryDC, g_currentColor);
// Рисование прямоугольника, который будет заполнен цветом, соответствующим пикселю под
// курсором.
Rectangle(g_hMemoryDC, g_colorRectangle.left, g_colorRectangle.top, g_colorRectangle.right,
g_colorRectangle.bottom);
// Вывод текста, содержащего значения каждой составляющей для текущего цвета.
DrawText(g_hMemoryDC, g_szText, _tcslen(g_szText), &g_textRectangle, DT_CENTER);
// Отправка приложению сообщения WM_PAINT.
InvalidateRect(hWindow, NULL, TRUE);
}
// Запоминание текущего цвета.
previousColor = g_currentColor;
}
开发者ID:ShartepStudy,项目名称:STUDY,代码行数:46,代码来源:WinMain.cpp
示例11: tImg
void cImage::Flip() {
if ( NULL != mPixels ) {
cImage tImg( mHeight, mWidth, mChannels );
for ( eeUint y = 0; y < mHeight; y++ )
for ( eeUint x = 0; x < mWidth; x++ )
tImg.SetPixel( y, x, GetPixel( x, mHeight - 1 - y ) );
ClearCache();
mPixels = tImg.GetPixels();
mWidth = tImg.Width();
mHeight = tImg.Height();
tImg.AvoidFreeImage( true );
}
}
开发者ID:dogtwelve,项目名称:eepp,代码行数:17,代码来源:cimage.cpp
示例12: GetPixel
/*
*--------------------------------------------------------------------------------
* 函数名: BeginDraw
* 功能 : 用当前画刷颜色填充封闭区域
* 参数 : CPoint ptPoint - 当前的坐标点
* 算法 : 重载函数,调用 API 函数进行填充
*--------------------------------------------------------------------------------
*/
void CPaintTub::BeginDraw(const CPoint& ptPoint)
{
HDC hDC = m_hDC;
// 得到当前坐标点的颜色
COLORREF crCurPos = GetPixel(hDC, ptPoint.x, ptPoint.y);
HBRUSH hBrush = CreateSolidBrush(m_crPenColor);
HBRUSH hOldBrush = (HBRUSH) SelectObject(hDC, hBrush);
// 填充颜色, Windows API
ExtFloodFill(hDC, ptPoint.x, ptPoint.y, crCurPos, FLOODFILLSURFACE);
SelectObject(hDC, hOldBrush);
DeleteObject(hOldBrush);
DeleteObject(hBrush);
}
开发者ID:obabywawa,项目名称:UPIM,代码行数:25,代码来源:PaintTub.cpp
示例13: GPwritebitmap
int GPwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
Gwidget_t *widget;
HDC gc;
COLORREF color;
char bufp[2048];
int bufi, x, y, w, h;
if (!bitmap) {
Gerr (POS, G_ERRNOBITMAP);
return -1;
}
if (
bitmap->canvas < 0 || bitmap->canvas >= Gwidgetn ||
!Gwidgets[bitmap->canvas].inuse
) {
Gerr (POS, G_ERRBADWIDGETID, bitmap->canvas);
return -1;
}
widget = &Gwidgets[bitmap->canvas];
if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
Gerr (POS, G_ERRNOTACANVAS, bitmap->canvas);
return -1;
}
gc = CreateCompatibleDC (GC);
SelectObject (gc, bitmap->u.bmap.orig);
fprintf (fp, "P6\n%d %d 255\n", (int) bitmap->size.x, (int) bitmap->size.y);
bufi = 0;
w = bitmap->size.x;
h = bitmap->size.y;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
color = GetPixel (gc, x, y);
bufp[bufi++] = GetRValue (color);
bufp[bufi++] = GetGValue (color);
bufp[bufi++] = GetBValue (color);
if (bufi + 3 >= 2048) {
fwrite (bufp, 1, bufi, fp);
bufi = 0;
}
}
}
if (bufi > 0)
fwrite (bufp, 1, bufi, fp);
DeleteDC (gc);
return 0;
}
开发者ID:AhmedAMohamed,项目名称:graphviz,代码行数:46,代码来源:gpcanvas.c
示例14: tooltip_get_cursor_height
/*
* tooltip_get_cursor_height - マウスカーソルの高さを取得
*/
static int tooltip_get_cursor_height(const HCURSOR hcursor)
{
HDC hdc, mdc;
HBITMAP hbmp, ret_hbmp;
ICONINFO icon_info;
int width, height;
int x, y;
// カーソルの大きさ取得
width = GetSystemMetrics(SM_CXCURSOR);
height = GetSystemMetrics(SM_CYCURSOR);
// カーソル(マスク)の描画
hdc = GetDC(NULL);
mdc = CreateCompatibleDC(hdc);
hbmp = CreateCompatibleBitmap(hdc, width, height);
ret_hbmp = SelectObject(mdc, hbmp);
DrawIconEx(mdc, 0, 0, hcursor, width, height, 0, NULL, DI_MASK);
// カーソルの高さ取得
for (y = height - 1; y >= 0; y--) {
for (x = 0; x < width; x++) {
if (GetPixel(mdc, x, y) != RGB(255, 255, 255)) {
break;
}
}
if (x < width) {
break;
}
}
SelectObject(mdc, ret_hbmp);
DeleteObject(hbmp);
DeleteDC(mdc);
ReleaseDC(NULL, hdc);
// ホットスポットの位置を取得
ZeroMemory(&icon_info, sizeof(ICONINFO));
GetIconInfo(hcursor, &icon_info);
if (icon_info.hbmMask != NULL) {
DeleteObject(icon_info.hbmMask);
}
if (icon_info.hbmColor != NULL) {
DeleteObject(icon_info.hbmColor);
}
return (((y < 0) ? height : y) - icon_info.yHotspot);
}
开发者ID:tobynet,项目名称:clcl,代码行数:49,代码来源:ToolTip.c
示例15: createGrayBitmap
HBITMAP createGrayBitmap( HBITMAP srcBmp, COLORREF transparent )
{
HBITMAP destBmp = NULL;
BITMAP bitmap;
HDC dcMem = NULL, dcSrc = NULL;
HBITMAP bmpOldSrc = NULL, bmpOldMem = NULL;
if( ( dcMem = CreateCompatibleDC( NULL ) ) && ( dcSrc = CreateCompatibleDC( NULL ) ) )
{
GetObject( srcBmp, sizeof( bitmap ), &bitmap );
if( ( destBmp = CreateBitmap( bitmap.bmWidth, bitmap.bmHeight,
bitmap.bmPlanes, bitmap.bmBitsPixel, NULL ) ) )
{
bmpOldMem = (HBITMAP)SelectObject( dcMem, destBmp );
bmpOldSrc = (HBITMAP)SelectObject( dcSrc, srcBmp );
if( bmpOldMem && bmpOldSrc )
{
BitBlt( dcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight,
dcSrc, 0, 0, SRCCOPY );
for( int i = 0; i < bitmap.bmWidth; ++i )
for( int j = 0; j < bitmap.bmHeight; ++j )
{
COLORREF color = GetPixel( dcMem, i, j );
if( color != transparent )
{
double grayScale = GetRValue( color ) * 0.3 +
GetGValue( color ) * 0.59 +
GetBValue( color ) * 0.11;
grayScale = grayScale / 2 + 128;
color = RGB( grayScale, grayScale, grayScale );
SetPixel( dcMem, i, j, color );
}
}
SelectObject( dcSrc, bmpOldSrc );
SelectObject( dcMem, bmpOldMem );
}
}
}
if( dcMem ) DeleteDC( dcMem );
if( dcSrc ) DeleteDC( dcSrc );
return destBmp;
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:46,代码来源:gui_bitmap.cpp
示例16: khui_ilist_add_masked
KHMEXP int KHMAPI
khui_ilist_add_masked(khui_ilist * il, HBITMAP hbm, COLORREF cbkg) {
HDC dcr,dci,dct,dcb;
HBITMAP hb_oldb, hb_oldi, hb_oldt;
int sx, i;
int x,y;
dcr = GetDC(NULL);
dci = CreateCompatibleDC(dcr);
dct = CreateCompatibleDC(dcr);
dcb = CreateCompatibleDC(dcr);
ReleaseDC(NULL,dcr);
i = il->nused++;
il->idlist[i] = -1;
sx = i * il->cx;
hb_oldb = SelectObject(dcb, hbm);
hb_oldi = SelectObject(dci, il->img);
hb_oldt = SelectObject(dct, il->mask);
SetBkColor(dct, RGB(0,0,0));
SetTextColor(dct, RGB(255,255,255));
BitBlt(dci, sx, 0, il->cx, il->cy, dcb, 0, 0, SRCCOPY);
for(y=0;y < il->cy; y++)
for(x=0; x<il->cx; x++) {
COLORREF c = GetPixel(dcb, x, y);
if(c==cbkg) {
SetPixel(dct, sx + x, y, RGB(255,255,255));
SetPixel(dci, sx + x, y, RGB(0,0,0));
} else {
SetPixel(dct, sx + x, y, RGB(0,0,0));
}
}
SelectObject(dct, hb_oldt);
SelectObject(dci, hb_oldi);
SelectObject(dcb, hb_oldb);
DeleteDC(dcb);
DeleteDC(dct);
DeleteDC(dci);
return i;
}
开发者ID:Brainiarc7,项目名称:pbis,代码行数:46,代码来源:rescache.c
示例17: ASSERT
/* randomly re-place one of two points that are too close to each other,
* move others that are too far from the centroid towards the centroid
*/
void OpticalFlow::AddNewFeatures(IplImage* rgbImage,
CPointVector& features,
CStatusVector& status,
int last_width, int last_height,
bool use_prob_distr)
{
ASSERT(m_pProbDistrProvider);
CDoubleMatrix distances;
DistanceMatrix(features, distances);
// discard the highest 15percent of distances when computing centroid
int discard_num_distances = (int)(0.15*(double)distances.size());
int centroid_index = FindCentroid(distances, discard_num_distances);
CvPoint2D32f centroid = features[centroid_index];
// double halfwidth = last_width/2.0;
// double halfheight = last_height/2.0;
// double left = centroid.x-halfwidth;
// double right = centroid.x+halfwidth;
// double top = centroid.y-halfheight;
// double bottom = centroid.y+halfheight;
for (int fcnt=m_num_features_tracked; fcnt<m_target_num_features; fcnt++) {
// try to find a location that was segmented as foreground color
int x, y;
double prob = 1.0;
int prob_cnt = 0;
do {
x = (int) (centroid.x-last_width/2.0+(rand()%last_width));
y = (int) (centroid.y-last_height/2.0+(rand()%last_height));
x = min(x, rgbImage->width-1);
y = min(y, rgbImage->height-1);
x = max(x, 0);
y = max(y, 0);
ColorBGR* color;
GetPixel(rgbImage, x, y, &color);
if (use_prob_distr) {
prob = m_pProbDistrProvider->LookupProb(*color);
}
prob_cnt++;
} while (prob<MIN_PROB_FOREGROUND && prob_cnt<20);
features[fcnt].x = (float)x;
features[fcnt].y = (float)y;
status[fcnt] = 0;
} // end for fcnt
}
开发者ID:B12040331,项目名称:handvu,代码行数:49,代码来源:OpticalFlow.cpp
示例18: _tcscpy
Font::Font(Surface *fs)
{
newcolor= false;
HDC hSurfaceDC;
COLORREF color;
int ch,klength, i;
FontSurface = fs;
hSurfaceDC = FontSurface->GetDC( false );
ascii= new TCHAR[256];
_tcscpy(ascii,TEXT(" !\"#$%&'()*+,-./0123456789:;<=>[email protected][\\]^_`abcdefghijklmnopqrstuvwxyz{|}~_"));
ch=0;
klength=0;
for (i=0; i<256; i++)
{
chardata[i].length=0;
chardata[i].offset=0;
}
for (i=0; i<fs->GetWidth(); i++)
{
color = GetPixel(hSurfaceDC,i,0);
//if (color == RGB(255,255,255)) // doesn't work in pocketpc, only desktop pc. white is not always white ? Help me with this.
if ((GetRValue(color)>0) && (GetGValue(color)>0) && (GetBValue(color)>0)) // had to use these instead.
{ // test for the width data on top of each char. Leave 1 blank channel when using color masks. use 255,0,255 for mask.
if (klength==0) chardata[ascii[ch]].offset=i;
klength++; // true, not a mask color so record length of char.
}
else
{ // it's a mask color so ignore.
if (klength!=0)
{
chardata[ascii[ch]].length=klength;
ch++;
}
klength=0;
}
}
FontSurface->ReleaseDC( hSurfaceDC );
FontSurface->SetColorMask(Color(255,0,255));
}
开发者ID:chandler55,项目名称:word-finder---pocket-pc,代码行数:45,代码来源:Font.cpp
示例19: GetObject
RGBA*
CClipboard::GetBitmapImageFromClipboard(int& width, int& height)
{
width = 0;
height = 0;
HBITMAP bitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
if (bitmap == NULL) {
return NULL;
}
BITMAP b;
GetObject(bitmap, sizeof(b), &b);
HDC dc = CreateCompatibleDC(NULL);
HBITMAP oldbitmap = (HBITMAP)SelectObject(dc, bitmap);
width = b.bmWidth;
height = b.bmHeight;
if (width <= 0 || height <= 0) {
width = 0;
height = 0;
return NULL;
}
RGBA* pixels = new RGBA[width * height];
if (pixels == NULL) {
width = 0;
height = 0;
return NULL;
}
memset(pixels, 255, sizeof(RGBA) * width * height);
// todo: GetPixel/GetR/G/BValue are extremely slow, fix it!
RGBA* ptr = pixels;
for (int iy = 0; iy < height; iy++) {
for (int ix = 0; ix < width; ix++)
{
COLORREF pixel = GetPixel(dc, ix, iy);
if (pixel != CLR_INVALID) {
ptr->red = GetRValue(pixel);
ptr->green = GetGValue(pixel);
ptr->blue = GetBValue(pixel);
}
ptr++;
}
}
SelectObject(dc, oldbitmap);
DeleteDC(dc);
return pixels;
}
开发者ID:sphere-group,项目名称:sphere,代码行数:45,代码来源:Clipboard.cpp
示例20: ComputeInverseColor
STATICFN DWORD NEAR ComputeInverseColor(
DWORD rgb)
{
HBITMAP hTempBit1;
HBITMAP hTempBit2;
HDC hTempDC1;
HDC hTempDC2;
HDC hdc;
HANDLE hOldObj1;
HANDLE hOldObj2;
DWORD rgbInv;
hdc = GetDC(ghwndMain);
hTempDC1 = CreateCompatibleDC(hdc);
hTempDC2 = CreateCompatibleDC(hdc);
/* create two temporary 1x1, 16 color bitmaps */
hTempBit1 = MyCreateBitmap(hdc, 1, 1, 16);
hTempBit2 = MyCreateBitmap(hdc, 1, 1, 16);
ReleaseDC(ghwndMain, hdc);
hOldObj1 = SelectObject(hTempDC1, hTempBit1);
hOldObj2 = SelectObject(hTempDC2, hTempBit2);
/* method for getting inverse color : set the given pixel (rgb) on
* one DC. Now blt it to the other DC using a SRCINVERT rop.
* This yields a pixel of the inverse color on the destination DC
*/
SetPixel(hTempDC1, 0, 0, rgb);
PatBlt(hTempDC2, 0, 0, 1, 1, WHITENESS);
BitBlt(hTempDC2, 0, 0, 1, 1, hTempDC1, 0, 0, SRCINVERT);
rgbInv = GetPixel(hTempDC2, 0, 0);
/* clean up ... */
SelectObject(hTempDC1, hOldObj1);
SelectObject(hTempDC2, hOldObj2);
DeleteObject(hTempBit1);
DeleteObject(hTempBit2);
DeleteDC(hTempDC1);
DeleteDC(hTempDC2);
/* ...and return the inverted RGB value */
return rgbInv;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:45,代码来源:colorwp.c
注:本文中的GetPixel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论