void CGrView::OnDraw(CDC* pDC)
{
CGrDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
void main(int c,int v)
{
if (c<4||c>5)
{
cout<<"usage: chessboardGenerator h w l [f]"
<<"\n\th\tlattice number in height"
<<"\n\tw\tlattice number in width"
<<"\n\tl\tlength of lattice in pixel"
<<"\n\tf\tfilename with proper extension for saving the generated image"<<endl;
exit(0);
}
int h=atoi(v[1]);
int w=atoi(v[2]);
int len=atoi(v[3]); int height=h*len;
int width=w*len;
IplImage* img=cvCreateImage(cvSize(width,height),8,1);
for (int i=0;i<h;i++)
{
for (int j=0;j<w;j++)
{
for (int lah=0;lah<len;lah++)
{
for (int law=0;law<len;law++)
{
unsigned char*p=(unsigned char*)img->imageData+(i*len+lah)*img->widthStep+j*len+law;
if ((i+j)%2)
{
*p=255;
}else
{
*p=0;
}
}
}
}
} string str;
if (c==5)
{
str=v[4];
}else
{
str="chessboard";
for (int i=1;i<4;i++)
{
str+="-";
str+=v[i];
}
str+=".jpg";
}
if(cvSaveImage(str.c_str(),img))
{
cout<<"succeed to save image:"<<str<<endl;
}else
{
cout<<"failed to save image:"<<str<<endl;
} cvReleaseImage(&img);
}
}
程序坚持出来报错为:D:\Program Files\Microsoft Visual Studio\MyProjects\gr\grView.cpp(62) : error C2601: 'main' : local function definitions are illegal
想高手求解啊????
{
CGrDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
void main(int c,int v)
{
if (c<4||c>5)
{
cout<<"usage: chessboardGenerator h w l [f]"
<<"\n\th\tlattice number in height"
<<"\n\tw\tlattice number in width"
<<"\n\tl\tlength of lattice in pixel"
<<"\n\tf\tfilename with proper extension for saving the generated image"<<endl;
exit(0);
}
int h=atoi(v[1]);
int w=atoi(v[2]);
int len=atoi(v[3]); int height=h*len;
int width=w*len;
IplImage* img=cvCreateImage(cvSize(width,height),8,1);
for (int i=0;i<h;i++)
{
for (int j=0;j<w;j++)
{
for (int lah=0;lah<len;lah++)
{
for (int law=0;law<len;law++)
{
unsigned char*p=(unsigned char*)img->imageData+(i*len+lah)*img->widthStep+j*len+law;
if ((i+j)%2)
{
*p=255;
}else
{
*p=0;
}
}
}
}
} string str;
if (c==5)
{
str=v[4];
}else
{
str="chessboard";
for (int i=1;i<4;i++)
{
str+="-";
str+=v[i];
}
str+=".jpg";
}
if(cvSaveImage(str.c_str(),img))
{
cout<<"succeed to save image:"<<str<<endl;
}else
{
cout<<"failed to save image:"<<str<<endl;
} cvReleaseImage(&img);
}
}
程序坚持出来报错为:D:\Program Files\Microsoft Visual Studio\MyProjects\gr\grView.cpp(62) : error C2601: 'main' : local function definitions are illegal
想高手求解啊????
void main(int c,int v)
{
以及倒数第二个 } 去掉