int MyPaint(int Country, int nColor)
{
if (Colors[Country] != -1)
{
if (Colors[Country] == nColor)
{
return 1;
}
else
{
return 0;
}
}

Colors[Country] = nColor;
int NewColor = 0;
if (nColor == 0) 
{
NewColor = 1;
}

for(int i = 0; i < N; ++i)
{
if (A[Country][i] == 1)
{
if (MyPaint(i, NewColor) == 0)
{
return 0;
}
}
}
return 1;
}
Esempio n. 2
0
//****消息处理函数**********************************
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	/*PAINTSTRUCT ps;
	HDC hdc;*/

	switch (message)
	{
	    case WM_TIMER:                      //时间消息  
            MyPaint(hdc);                   //在消息循环中加入处理WM_TIMER消息,当接收到此消息时便调用MyPaint()函数进行窗口绘图  
           printf("fd");
		  // MessageBox( NULL, "First blood! 你好,Visual Studio!", " 消息窗口", 0 );//显示一个消息框
			break;  
		//case WM_PAINT:						//窗口重绘消息
		//	hdc = BeginPaint(hWnd, &ps);
		//	//MyPaint(hdc);
		//	EndPaint(hWnd, &ps);
		//	break;
		case WM_DESTROY:					//窗口结束消息
			DeleteDC(mdc);
			DeleteObject(hbmp);
			DeleteObject(sprite);
			ReleaseDC(hWnd,hdc);
			for(int i=0;i<13;i++)
			{
				DeleteObject(arrow[i]);
			}
			KillTimer(hWnd,1);
			PostQuitMessage(0);
			break;
		default:							//其他消息
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Esempio n. 3
0
//****WinMain函数,程序入口点函数**************************************
int APIENTRY WinMain(HINSTANCE hInstance,
					 HINSTANCE hPrevInstance,
					 LPSTR     lpCmdLine,
					 int       nCmdShow)
{
	MSG msg;

	MyRegisterClass(hInstance);

	//初始化
	if (!InitInstance(hInstance, nCmdShow))
	{
		return FALSE;
	}
	GetMessage(&msg, NULL, NULL, NULL);//初始化msg
	//消息循环
	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			tNow = GetTickCount();
			if (tNow - tPre >= 100)
				MyPaint(hdc);
		}
	}

	return msg.wParam;
}
NBioAPI_RETURN MyCaptureCallback(NBioAPI_WINDOW_CALLBACK_PARAM_PTR_0 pCallbackParam, NBioAPI_VOID_PTR pUserParam)
{
   NBioBSPRollDemo_Widget* pWidget = (NBioBSPRollDemo_Widget*)pUserParam;
   
   memcpy(pWidget->m_pRollImage, pCallbackParam->lpImageBuf, pWidget->m_DeviceInfo0.ImageWidth * pWidget->m_DeviceInfo0.ImageHeight);

   MyPaint(pWidget);

   return NBioAPIERROR_NONE;
}
int main()
{
scanf("%d", &N);
int i;
int ch;
for(i = 0; i < N; ++i)
{
Colors[i] = -1;
for(;;)
{
scanf("%d", &ch);
if (ch == 0)
{
break;
}
A[ch-1][i] = 1;
A[i][ch-1] = 1;
}
}

int Bad = 0;
for(i = 0; i < N; ++i)
{
if (Colors[i] == -1)
{
if (MyPaint(i, 0) == 0)
{
Bad = 1;
break;
}
}
}

if (Bad == 1)
{
printf("-1\n");
}
else
{
for(int j = 0; j < N; ++j)
{
printf("%d", Colors[j]);
}
printf("\n");
}
return 0;
}
Esempio n. 6
0
//****初始化函数*************************************
// 加载位图并设定各初始值
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HBITMAP bmp;
	hInst = hInstance;
	int i;

	hWnd = CreateWindow("canvas", "绘图窗口" , WS_OVERLAPPED   |   WS_SYSMENU   |WS_MINIMIZEBOX,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	if (!hWnd)
	{
		return FALSE;
	}

	MoveWindow(hWnd,10,10,640,480,true);
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	hdc = GetDC(hWnd);
	mdc = CreateCompatibleDC(hdc);
	bufdc = CreateCompatibleDC(hdc);

	bmp = CreateCompatibleBitmap(hdc,640,480);  //建立一个空位图并放入mdc中
	SelectObject(mdc,bmp);


	//加载各张恐龙跑动图及背景图,这里以0,1,2,3来代表恐龙的上,下,左,右移动
	draPic[0] = (HBITMAP)LoadImage(NULL,"f/dra0.bmp",IMAGE_BITMAP,528,188,LR_LOADFROMFILE);
	draPic[1] = (HBITMAP)LoadImage(NULL,"f/dra1.bmp",IMAGE_BITMAP,544,164,LR_LOADFROMFILE);
	draPic[2] = (HBITMAP)LoadImage(NULL,"f/dra2.bmp",IMAGE_BITMAP,760,198,LR_LOADFROMFILE);
	draPic[3] = (HBITMAP)LoadImage(NULL,"f/dra3.bmp",IMAGE_BITMAP,760,198,LR_LOADFROMFILE);
	bg = (HBITMAP)LoadImage(NULL,"f/bg.bmp",IMAGE_BITMAP,640,480,LR_LOADFROMFILE);

	//设定所有恐龙初始的贴图坐标都为(200,200),初始的移动方向都为向左。
	for(i=0;i<draNum;i++)
	{
		dra[i].dir = 3;    //起始方向
		dra[i].x = 200;	   //贴图的起始X坐标
		dra[i].y = 200;    //贴图的起始Y坐标
	}

	MyPaint(hdc);

	return TRUE;
}
Esempio n. 7
0
/*********************************************************************************************
>	afx_msg void CRenderWnd::OnPaint()

	Author:		Justin_Flude (Xara Group Ltd) <*****@*****.**>
	Created:	ages ago
	Inputs:		-
	Outputs:	-
	Returns:	-
	Purpose:	Creates a CPaintDC and sends a private WM_RENDERVIEW message, together with
				a pointer to the CPaintDC in the LPARAM, to the parent CCamView. Uses a
				CCPaintDC so we can get to the rectangle list subsequently.
	Errors:		-
	Scope:	    Protected
	SeeAlso:    CCamView::OnRenderView()

**********************************************************************************************/ 
void CRenderWnd::OnPaint( wxPaintEvent &evnt )
{
	if ((!CCamApp::IsDisabled()) && (!PrintMonitor::IsPrintingNow()))
	{
		CCPaintDC dc(this);
//		wxPalette* OldPal = PaletteManager::StartPaintPalette(&dc);

		if (m_pView)
			m_pView->OnDraw(dc.GetDC());

//		PaletteManager::StopPaintPalette(&dc, OldPal);
	}
	else
	{
		// if we were printing, we have to draw something - white will do
		if (PrintMonitor::IsPrintingNow())
		{
			// Draw a white rectangle here
			wxPaintDC MyPaint(this);

			// Lets have a white brush...
			MyPaint.SetBrush(wxBrush(wxColour(*wxWHITE)));
			MyPaint.SetPen(*wxTRANSPARENT_PEN);

			wxRegionIterator upd(GetUpdateRegion()); // get the update rect list

			while (upd)
			{
				wxRect rect(upd.GetRect());
				MyPaint.DrawRectangle(rect);
				upd++;
			}

  			// ask for a full redraw at the end
			PrintMonitor::WantFullRedraw(TRUE);
		}
		else
		{
			wxPaintDC dc( this );								// Clear paint condition 
		}
	}
}
Esempio n. 8
0
void GLWidget::PaintViewportZ()
{
    //设置右上视口中物体的颜色
    glColor3f(1,0,0);
    //承接上一视口的观察矩阵  
    glLoadIdentity();
    //设置观察点在Z轴的正方向  
    gluLookAt(0,0,5,0,0,0,0,1,0);
    //设置投影矩阵  
    glMatrixMode(GL_PROJECTION);  
    glLoadIdentity();
    //设置投影区域,数字选择参照红书,第二项比例为右上视口的比例  
    gluPerspective(60, (GLfloat)mywidth*0.75/(GLfloat)myheight,0.1,10.0);  
    glMatrixMode(GL_MODELVIEW);  
    //设置视口为右上视口  
    glViewport(3*mywidth/4, 2*myheight/3, mywidth/4, myheight/3);  
    //鼠标控制交互,保存上一时刻与下一时刻的位置
    glPushMatrix();
    //绘制实物
    MyPaint();
    glPopMatrix();
}
Esempio n. 9
0
//****初始化函数*************************************
// 1.建立与窗口DC兼容的内存DC
// 2.从文件加载位图并存至内存DC中
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;
	HDC hdc;
	char filename[50]="";
	hInst = hInstance;

	hWnd = CreateWindow("canvas", "绘图窗口" , WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	if (!hWnd)
	{
		return FALSE;
	}

	MoveWindow(hWnd,10,10,800,600,true);
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	hdc = GetDC(hWnd);
	mdc = CreateCompatibleDC(hdc);

	hbmp = (HBITMAP)LoadImage(NULL,"bg.bmp",IMAGE_BITMAP,800,600,LR_LOADFROMFILE); 
    sprite = (HBITMAP)LoadImage(NULL,"sprite.bmp",IMAGE_BITMAP,225,225,LR_LOADFROMFILE); 
    for(int i=1;i<14;i++)
	{
		sprintf(filename,"%d.bmp",i);
	   arrow[i]=(HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,200,200,LR_LOADFROMFILE);
	}
	TextOut(mdc,0,0,"fnsdf",5); 
	num=1;
    SetTimer(hWnd,1,500,NULL);
	MyPaint(hdc);
	//MessageBox( NULL, "First blood! 你好,Visual Studio!", " 消息窗口", 0 );//显示一个消息框
	//ReleaseDC(hWnd,hdc);
	printf("fd");
	return TRUE;
}
Esempio n. 10
0
void GLWidget::PaintMainViewport()
{
    //设置主视口中物体的颜色
    glColor3f(1,0,0);
    //承接上一视口的观察矩阵  
    glLoadIdentity();
    //设置观察点在Z轴的正方向  
    gluLookAt(0,0,100,0,0,0,0,1,0);
    //设置投影矩阵  
    glMatrixMode(GL_PROJECTION);  
    glLoadIdentity();
    //设置投影区域,数字选择参照红书,第二项比例为左侧主视口的比例  
    //gluPerspective(60, (GLfloat)mywidth*0.75/(GLfloat)myheight,0.1,10.0);  
    glOrtho(-200.0,200.0,-200.0,200.0,-300.0,300.0);
	//glOrtho(-100,200,-100,200,-100,100);
	glMatrixMode(GL_MODELVIEW);  
    //设置视口为左侧主视口  
    glViewport(0, 0, 3*mywidth/4, myheight);  
    //鼠标控制交互,保存上一时刻与下一时刻的位置
    glPushMatrix();
    //绘制实物
    MyPaint();
    glPopMatrix();
}
void ribi::QtBeerWanterWidget::paintEvent(QPaintEvent *)
{
  QPainter painter(this);

  std::get<0>(m_background_rgb) = Modify(std::get<0>(m_background_rgb));
  std::get<1>(m_background_rgb) = Modify(std::get<1>(m_background_rgb));
  std::get<2>(m_background_rgb) = Modify(std::get<2>(m_background_rgb));

  QPixmap p(this->width(),this->height());
  MyPaint(
    p,
    std::get<0>(m_background_rgb),
    std::get<1>(m_background_rgb),
    std::get<2>(m_background_rgb)
  );
  painter.drawPixmap(0,0,p);

  assert(m_sprite);
  painter.drawPixmap(
    m_dialog->GetSpriteX(),
    m_dialog->GetSpriteY(),
    *m_sprite.get()
  );
}
Esempio n. 12
0
//****初始化函数*************************************
// 加载位图并设定各初始值
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HBITMAP bmp;
	hInst = hInstance;

	hWnd = CreateWindow("canvas", "绘图窗口", WS_OVERLAPPEDWINDOW,
						CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	if (!hWnd)
	{
		return FALSE;
	}

	MoveWindow(hWnd, 10, 10, 640, 480, true);
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	hdc = GetDC(hWnd);
	mdc = CreateCompatibleDC(hdc);
	bufdc = CreateCompatibleDC(hdc);

	bmp = CreateCompatibleBitmap(hdc, 640, 480);  //建立一个空位图并放入mdc中
	SelectObject(mdc, bmp);


	// 加载各张恐龙跑动图及背景图,这里以0,1,2,3来代表恐龙的上,下,左,右移动
	draPic[0] = (HBITMAP)LoadImage(NULL, "dra0.bmp", IMAGE_BITMAP, 528, 188, LR_LOADFROMFILE);
	draPic[1] = (HBITMAP)LoadImage(NULL, "dra1.bmp", IMAGE_BITMAP, 544, 164, LR_LOADFROMFILE);
	draPic[2] = (HBITMAP)LoadImage(NULL, "dra2.bmp", IMAGE_BITMAP, 760, 198, LR_LOADFROMFILE);
	draPic[3] = (HBITMAP)LoadImage(NULL, "dra3.bmp", IMAGE_BITMAP, 760, 198, LR_LOADFROMFILE);
	bg = (HBITMAP)LoadImage(NULL, "bg.bmp", IMAGE_BITMAP, 640, 480, LR_LOADFROMFILE);

	MyPaint(hdc);

	return TRUE;
}
Esempio n. 13
0
void NBioBSPRollDemo_Widget::paintEvent(QPaintEvent *)
{
   MyPaint(this);
}