您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetPixel函数代码示例

51自学网 2021-06-01 21:12:41
  C++
这篇教程C++ GetPixel函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetPixel函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPixel函数的具体用法?C++ GetPixel怎么用?C++ GetPixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetPixel函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例14: tooltip_get_cursor_height

/* * tooltip_get_cursor_height - マウスカ
C++ GetPixelBlue函数代码示例
C++ GetPitch函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。