你好,在用VC++对图像进行处理时要进行边采边算,请问有这样的例子么?谢谢
2个回答
展开全部
而成.
a. 新建工程1_1,选择单文档,完成
b. 在view类加变量int ituxing,并在构造函数里赋值为ituxing=0;
c. 在OnDraw(CDC* pDC)函数上添上以下语句:
void CMy1_1View::OnDraw(CDC* pDC)
{
CMy1_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//清除当前图形
CBrush mybrush1;
mybrush1.CreateSolidBrush(RGB(255,255,255));
CRect myrect1(0,0,1024,768);
pDC->FillRect(myrect1,&mybrush1);
//判断当前图形ituxing
if(ituxing==1)
//ituxing=1,画矩形
pDC->Rectangle(20,20,89,89);
else if(ituxing==2)
//ituxing=2,画圆
pDC->Ellipse(20,20,89,89);
else
//否则,画三角形
{
pDC->MoveTo(20,20);
pDC->LineTo(89,45);
pDC->LineTo(20,89);
pDC->LineTo(20,20);
}
}
d. 添加OnTimer(UINT nIDEvent)和OnCreate(LPCREATESTRUCT lpCreateStruct),并加上语句如下:
void CMy1_1View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
//获取指针pdc
CDC *pDC=GetDC();
//调用OnDraw(pDC)重画
OnDraw(pDC);
//使ituxing循环
ituxing=(ituxing+1)%3;
CView::OnTimer(nIDEvent);
}
int CMy1_1View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
//设置更新时间
SetTimer(1, 750, NULL);
return 0;
}
e. 完成。
2. 位变
即同一个图形或位图依次在不同的位置上出现而形成动画.
实例1_2:
a. 复制实例1_1文件夹,改名为1_2。
把void CMy1_1View::OnTimer(UINT nIDEvent)中的ituxing=(ituxing+1)%3;改为ituxing=(ituxing+1)%10;
b. 把OnDraw(CDC* pDC)函数改为:
void CMy1_1View::OnDraw(CDC* pDC)
{
CMy1_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//清除当前图形
CBrush mybrush1;
mybrush1.CreateSolidBrush(RGB(255,255,255));
CRect myrect1(0,0,1024,768);
pDC->FillRect(myrect1,&mybrush1);
//用当前图形位置ituxing
//画圆
pDC->Ellipse(30*ituxing,30*ituxing,30*ituxing+50,30*ituxing+50);
}
c. 执行,OK!
3. 色变
即利用不同颜色的转变而形成有动感的图画。(图1-3)
实例1_3:
a. 新建单文档工程1_3。
b. 添加参数int icolor并赋值为0。
c. 添加函数OnTimer(UINT nIDEvent)和OnCreate(LPCREATESTRUCT lpCreateStruct),并添加语句如下:
void CMy1_3View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
icolor+=1;
//此函数使客户区失效,以致重画
Invalidate();
CView::OnTimer(nIDEvent);
}
int CMy1_3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1,750,NULL);
return 0;
}
d. 最后在OnDraw(CDC* pDC)加上画圆语句:
void CMy1_3View::OnDraw(CDC* pDC)
{
CMy1_3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//获取icolor值
int i=icolor;
//在不同位置画四个不同颜色的圆
CBrush brush1(RGB(20+(64*i)%255,140+(64*i)%255,210*(64+i)%255));
CBrush*pOldBrush1=pDC->SelectObject(&brush1);
pDC->Ellipse(300,200,350,250);
pDC->SelectObject(pOldBrush1);
CBrush brush2(RGB(84+(64*i)%255,204+(64*i)%255,24+(64*i)%255));
CBrush*pOldBrush2=pDC->SelectObject(&brush2);
pDC->Ellipse(350,200,400,250);
pDC->SelectObject(pOldBrush2);
CBrush brush3(RGB(148+(64*i)%255,14+(64*i)%255,88+(64*i)%255));
CBrush*pOldBrush3=pDC->SelectObject(&brush3);
pDC->Ellipse(300,250,350,300);
pDC->SelectObject(pOldBrush3);
CBrush brush4(RGB(212+(64*i)%255,78+(64*i)%255,152+(64*i)%255));
CBrush*pOldBrush4=pDC->SelectObject(&brush4);
pDC->Ellipse(350,250,400,300);
pDC->SelectObject(pOldBrush4);
}
e. 完成。
a. 新建工程1_1,选择单文档,完成
b. 在view类加变量int ituxing,并在构造函数里赋值为ituxing=0;
c. 在OnDraw(CDC* pDC)函数上添上以下语句:
void CMy1_1View::OnDraw(CDC* pDC)
{
CMy1_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//清除当前图形
CBrush mybrush1;
mybrush1.CreateSolidBrush(RGB(255,255,255));
CRect myrect1(0,0,1024,768);
pDC->FillRect(myrect1,&mybrush1);
//判断当前图形ituxing
if(ituxing==1)
//ituxing=1,画矩形
pDC->Rectangle(20,20,89,89);
else if(ituxing==2)
//ituxing=2,画圆
pDC->Ellipse(20,20,89,89);
else
//否则,画三角形
{
pDC->MoveTo(20,20);
pDC->LineTo(89,45);
pDC->LineTo(20,89);
pDC->LineTo(20,20);
}
}
d. 添加OnTimer(UINT nIDEvent)和OnCreate(LPCREATESTRUCT lpCreateStruct),并加上语句如下:
void CMy1_1View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
//获取指针pdc
CDC *pDC=GetDC();
//调用OnDraw(pDC)重画
OnDraw(pDC);
//使ituxing循环
ituxing=(ituxing+1)%3;
CView::OnTimer(nIDEvent);
}
int CMy1_1View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
//设置更新时间
SetTimer(1, 750, NULL);
return 0;
}
e. 完成。
2. 位变
即同一个图形或位图依次在不同的位置上出现而形成动画.
实例1_2:
a. 复制实例1_1文件夹,改名为1_2。
把void CMy1_1View::OnTimer(UINT nIDEvent)中的ituxing=(ituxing+1)%3;改为ituxing=(ituxing+1)%10;
b. 把OnDraw(CDC* pDC)函数改为:
void CMy1_1View::OnDraw(CDC* pDC)
{
CMy1_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//清除当前图形
CBrush mybrush1;
mybrush1.CreateSolidBrush(RGB(255,255,255));
CRect myrect1(0,0,1024,768);
pDC->FillRect(myrect1,&mybrush1);
//用当前图形位置ituxing
//画圆
pDC->Ellipse(30*ituxing,30*ituxing,30*ituxing+50,30*ituxing+50);
}
c. 执行,OK!
3. 色变
即利用不同颜色的转变而形成有动感的图画。(图1-3)
实例1_3:
a. 新建单文档工程1_3。
b. 添加参数int icolor并赋值为0。
c. 添加函数OnTimer(UINT nIDEvent)和OnCreate(LPCREATESTRUCT lpCreateStruct),并添加语句如下:
void CMy1_3View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
icolor+=1;
//此函数使客户区失效,以致重画
Invalidate();
CView::OnTimer(nIDEvent);
}
int CMy1_3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1,750,NULL);
return 0;
}
d. 最后在OnDraw(CDC* pDC)加上画圆语句:
void CMy1_3View::OnDraw(CDC* pDC)
{
CMy1_3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//获取icolor值
int i=icolor;
//在不同位置画四个不同颜色的圆
CBrush brush1(RGB(20+(64*i)%255,140+(64*i)%255,210*(64+i)%255));
CBrush*pOldBrush1=pDC->SelectObject(&brush1);
pDC->Ellipse(300,200,350,250);
pDC->SelectObject(pOldBrush1);
CBrush brush2(RGB(84+(64*i)%255,204+(64*i)%255,24+(64*i)%255));
CBrush*pOldBrush2=pDC->SelectObject(&brush2);
pDC->Ellipse(350,200,400,250);
pDC->SelectObject(pOldBrush2);
CBrush brush3(RGB(148+(64*i)%255,14+(64*i)%255,88+(64*i)%255));
CBrush*pOldBrush3=pDC->SelectObject(&brush3);
pDC->Ellipse(300,250,350,300);
pDC->SelectObject(pOldBrush3);
CBrush brush4(RGB(212+(64*i)%255,78+(64*i)%255,152+(64*i)%255));
CBrush*pOldBrush4=pDC->SelectObject(&brush4);
pDC->Ellipse(350,250,400,300);
pDC->SelectObject(pOldBrush4);
}
e. 完成。
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询