压力测试图片生成代码
IplImage * pImg = NULL; CString strName; /* CvScalar s; s.val[0]=s.val[1]=s.val[2]=s.val[3]=0;//black //1111-9999 for (int kk = 1111;kk<2999;kk++) { if(pImg != NULL) cvReleaseImage(&pImg); pImg =cvLoadImage( "压力测试专用文件夹\\75tv.jpg" , 1 ) ; float nwidth = (float)pImg->width/24; float nheight = (float)pImg->height/30; strName.Format("%d",kk); //得到每一位然后去涂。。。 int num1 = strName.GetAt(0)-48; int num2 = strName.GetAt(1) -48; int num3 = strName.GetAt(2)-48; int num4 = strName.GetAt(3)-48; //3 for (int x = 2*nwidth;x<3*nwidth;x++) { for (int y = (5+num1)*nheight;y<(5+num1+1)*nheight;y++) { cvSet2D(pImg,y,x,s); } //strName.Format("压力测试专用文件夹\\%d.jpg",strName); //cvSaveImage (strName,pImg); } //4 for (int x2 = 3*nwidth;x2<4*nwidth;x2++) { for (int y2 = (5+num2)*nheight;y2<(5+num2+1)*nheight;y2++) { cvSet2D(pImg,y2,x2,s); } //strName.Format("压力测试专用文件夹\\%d.jpg",strName); //cvSaveImage (strName,pImg); } //5 for (int x3 = 4*nwidth;x3<5*nwidth;x3++) { for (int y3 = (5+num3)*nheight;y3<(5+num3+1)*nheight;y3++) { cvSet2D(pImg,y3,x3,s); } //strName.Format("压力测试专用文件夹\\%d.jpg",strName); //cvSaveImage (strName,pImg); } //6 for (int x4 = 5*nwidth;x4<6*nwidth;x4++) { for (int y4 = (5+num4)*nheight;y4<(5+num4+1)*nheight;y4++) { cvSet2D(pImg,y4,x4,s); } //strName.Format("压力测试专用文件夹\\%d.jpg",strName); //cvSaveImage (strName,pImg); } strName.Format("压力测试专用文件夹\\%d.jpg",kk); cvSaveImage (strName,pImg); } */ // //再开始合成 CvScalar s; s.val[0]=s.val[1]=s.val[2]=s.val[3]=255;//white IplImage * pOKImg = cvCreateImage(cvSize(800,600),8,1); for (int u =1111;u<2999;u++) { for (int a = 0;a<800;a++) { for (int b = 0;b<600;b++) { cvSet2D(pOKImg,b,a,s); } } //加载图片 CString strName; strName.Format("压力测试专用文件夹\\%d.jpg",u); IplImage * pImg = cvLoadImage(strName,0); CvScalar s2; for (int i = 0 ;iwidth;i++) { for (int j=0 ; j height;j++) { s2=cvGet2D(pImg,j,i); cvSet2D(pOKImg,j+30,i+30,s2); } } strName.Format("C:\\Documents and Settings\\Administrator\\桌面\\压力测试用图片\\%d.jpg",u); cvSaveImage (strName,pOKImg); } /* for (int i = 0 ;i<3 ;i++)//行循环 { for (int j = 0 ;j<9 ;j++)//列循环 { for (int y = (6+j)*nheight;y<(6+j+1)*nheight;y++) { cvSet2D(pImg,y,x,s); } for (int m = 0 ;m<9 ;m++)//列循环 { for (int n = 0 ;n<9 ;n++)//列循环 { for (int x = (3+i)*nwidth;x<(3+i+1)*nwidth;x++) { for (int y = (6+j)*nheight;y<(6+j+1)*nheight;y++) { cvSet2D(pImg,y,x,s); } strName.Format("压力测试专用文件夹\\%d%d.jpg",i,j); cvSaveImage (strName,pImg); } } } } } */