| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 300 人关注过本帖
标题:如何能使绘制的图形转化为位图再呈现在屏幕上
只看楼主 加入收藏
yangqiong
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-7-14
收藏
 问题点数:0 回复次数:0 
如何能使绘制的图形转化为位图再呈现在屏幕上
我用角度循环,画点的方法在OnDraw函数中画图,画图的过程非常慢,所以我不希望每一次改变窗口的大小图形都会重绘,有没有办法在图形绘制好之后自动转为位图,再呈现在屏幕上,这样重绘的过程会快一些。代码如下。
// 以下循环于OnDraw函数结束处终止,该循环使得在ψ2取输入值的前提下,ψ1取到0-2π所有值,ψ取到-1/2π-0之间所有值
if(m_ok==true){
for(fai1=0.0;        fai1<2.0*pi;          fai1+=0.004)
        for( fai=-pi/2.0;     fai<0;         fai+=0.003){
            if(fai2_imput == 0){
                fai2=0.0;
            }else{
                fai2 = pi/(180/fai2_imput);
            }//end of if ... else ...


// 下面一段程序将四轴坐标转化为三轴坐标,此程序中以小写字母 {hkil}<uvtw>表示四轴坐标,以大写字母{HKL}<UVW>表示三轴坐标
//d_uvw,d_hkl分别为[UVW],[HKL]的模
qx=direction,qm=plane;
            for( p=slip_twin_system4;p<slip_twin_system4+number;p++){
                d_uvw=sqrt(3.0*aa*aa*((p->u)+(p->v)/2.0)*((p->u)+(p->v)/2.0)+9.0*(p->v)*(p->v)*aa*aa/4.0+(p->w)*(p->w)*cc*cc);
                d_hkl=sqrt((2.0*(p->h)+(p->k))*(2.0*(p->h)+(p->k))*cc*cc+3.0*(p->k)*(p->k)*cc*cc+3.0*(p->l)*(p->l)*aa*aa);
                qx->U=(sqrt(3.0)*(p->u)+sqrt(3.0)*(p->v)/2.0)*aa/d_uvw;
                qx->V=3.0*(p->v)*aa/d_uvw/2.0;
                qx->W=(p->w)*cc/d_uvw;
                qm->H=(2.0*(p->h)+(p->k))*cc/d_hkl;
                qm->K=sqrt(3.0)*(p->k)*cc/d_hkl;
                qm->L=sqrt(3.0)*(p->l)*aa/d_hkl;
                qx++;qm++;
            }//end of for ...

//下面一段程序定义欧拉变换的矩阵

            Euler[0][0]=cos(fai1)*cos(fai2)-sin(fai1)*sin(fai2)*cos(fai);
            Euler[0][1]=sin(fai1)*cos(fai2)+sin(fai2)*cos(fai1)*cos(fai);
            Euler[0][2]=sin(fai2)*sin(fai);
            Euler[1][0]=(-1.0)*cos(fai1)*sin(fai2)-sin(fai1)*cos(fai2)*cos(fai);
            Euler[1][1]=cos(fai1)*cos(fai2)*cos(fai)-sin(fai1)*sin(fai2);
            Euler[1][2]=sin(fai)*cos(fai2);
            Euler[2][0]=sin(fai1)*sin(fai);
            Euler[2][1]=(-1.0)*cos(fai1)*sin(fai);
            Euler[2][2]=cos(fai);
for(ii=0;ii<=2;ii++)
                for(jj=0;jj<=2;jj++)
                    Euler_1[ii][jj]=Euler[jj][ii];
            
            for(ii=0;ii<=2;ii++)
                for(jj=0;jj<=2;jj++)
                    Euler[ii][jj]=Euler_1[ii][jj];

//下面一段程序将用三轴坐标表示的滑移面及滑移方向赋予矩阵 slip_twin_system3中
qx=direction;
            for(qm=plane;qm<plane+number;qm++){
                slip_twin_system3[0][0]=qx->U;
                slip_twin_system3[1][0]=qx->V;
                slip_twin_system3[2][0]=qx->W;
                slip_twin_system3[0][2]=qm->H;
                slip_twin_system3[1][2]=qm->K;
                slip_twin_system3[2][2]=qm->L;
                slip_twin_system3[0][1]=1.0;
                slip_twin_system3[1][1]=1.0;
                slip_twin_system3[2][1]=1.0;

//下面一段程序实现对三轴坐标表示的滑移系,孪生系的欧拉变换,定义Euler_i,Euler_j,Euler_k,Euler_2为中间变量   
                for(Euler_i=0;Euler_i<=2;Euler_i++)
                    for(Euler_j=0;Euler_j<=2;Euler_j++)
                        Euler_2[Euler_i][Euler_j]=0.0;
               
               
                for(Euler_i=0;Euler_i<=2;Euler_i++)
                    for(Euler_j=0;Euler_j<=2;Euler_j++)
                        for(Euler_k=0;Euler_k<=2;Euler_k++)
                            Euler_2[Euler_i][Euler_j]+=Euler[Euler_i][Euler_k]*slip_twin_system3[Euler_k][Euler_j];
               
                qx->U=Euler_2[0][0];
                qx->V=Euler_2[1][0];
                qx->W=Euler_2[2][0];
                qm->H=Euler_2[0][2];
                qm->K=Euler_2[1][2];
                qm->L=Euler_2[2][2];
                qx++;
                }//end of for ...

//下面一段程序计算δx,δy,δz, τxy,τyz,τxz产生的分切应力,将其赋予数组shear_stress
for(ii=0;ii<=(number-1);ii++)
                shear_stress[ii]=0.0;
            for(ii=0;ii<=(number1-1);ii++)
                schmid_max[ii]=0.0;
                        
            ii=0;
            qm=plane;
            for(qx=direction;qx<direction+number;qx++){
                shear_stress[ii]=0.0;
               
                // 下面一段程序将正应力产生的分切应力赋予数组shear_stress
                shear_stress[ii]+=(qx->U)*(qm->H)*δxx;
                shear_stress[ii]+=(qm->K)*(qx->V)*δyy;
                shear_stress[ii]+=(qm->L)*(qx->W)*δzz;
               
                if(τxz!=0||τyz!=0){

            // 下面一段程序计算切应力τxz在滑移面滑移方向产生的分切应力
            // 下面一段程序将滑移面与001面交线的指数赋予intersection 数组                                                         
                intersection [0] = -(qm->K);
                intersection [1] = (qm->H);
                intersection [2] = 0;
               
               
                //下面一段程序将交线与滑移方向的夹角赋予κ
                itmp= (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * (sqrt((qx->U)*(qx->U) + (qx->V)*(qx->V) + (qx->W)*(qx->W)));
                itmpa = intersection[0] * (qx->U) + intersection[1] * (qx->V) + intersection[2] * (qx->W);
                κ= acos(itmpa/itmp);
               
                   // 下面一段程序将滑移面(HKL)与001面的夹角赋予ψ
                itmp = 1;
                itmpa = (qm->L);
                ψ = acos(itmpa/itmp);
                ψ_2 = 2 * ψ;
               
               
                //下面一段程序将分切应力τxz(100)与交线的夹角赋予α
                if(τxz!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[0] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τxz*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));}

               
                //下面一段程序计算切应力τyz在滑移面滑移方向产生的分切应力
                //下面一段程序将分切应力τyz(010)与交线的夹角赋予α
                if(τyz!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[1] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τyz*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));}
                }


                if(τxy!=0||τxz!=0){
                // 下面一段程序计算切应力τzx在滑移面滑移方向产生的分切应力
                // 下面一段程序将滑移面与100面交线的指数赋予intersection 数组                                                         
                intersection [0] = 0;
                intersection [1] = -(qm->L);
                intersection [2] = (qm->K);
                //下面一段程序将交线与滑移方向的夹角赋予κ
                itmp= (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * (sqrt((qx->U)*(qx->U) + (qx->V)*(qx->V) + (qx->W)*(qx->W)));
                itmpa = intersection[0] * (qx->U) + intersection[1] * (qx->V) + intersection[2] * (qx->W);
                κ= acos(itmpa/itmp);
               
               
                   // 下面一段程序将滑移面(HKL)与100面的夹角赋予ψ
                itmp = 1;
                itmpa = (qm->H);
                ψ = acos(itmpa/itmp);
                ψ_2 = 2 * ψ;
               
                //下面一段程序将分切应力τzx (001)与交线的夹角赋予α
                if(τzx!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[2] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τzx*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));}


                //下面一段程序计算切应力τyx在滑移面滑移方向产生的分切应力
                //下面一段程序将分切应力τyx(010)与交线的夹角赋予α
                if(τyx!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[1] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τyx*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));}

                }
                 
                if(τzy!=0||τxz!=0){
                // 下面一段程序计算切应力τzy在滑移面滑移方向产生的分切应力
                // 下面一段程序将滑移面与010面交线的指数赋予intersection 数组                                                         
                intersection [0] = (qm->L);
                intersection [1] = 0;
                intersection [2] = -(qm->H);
                //下面一段程序将交线与滑移方向的夹角赋予κ
                itmp= (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * (sqrt((qx->U)*(qx->U) + (qx->V)*(qx->V) + (qx->W)*(qx->W)));
                itmpa = intersection[0] * (qx->U) + intersection[1] * (qx->V) + intersection[2] * (qx->W);
                κ= acos(itmpa/itmp);
            
                   // 下面一段程序将滑移面(HKL)与010面的夹角赋予ψ
                itmp = 1;
                itmpa = (qm->K);
                ψ = acos(itmpa/itmp);
                ψ_2 = 2 * ψ;
               
                //下面一段程序将分切应力τzy (001)与交线的夹角赋予α
                if(τzy!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[2] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τzy*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));}

               
                //下面一段程序计算切应力τxy在滑移面滑移方向产生的分切应力
                //下面一段程序将分切应力τxy(100)与交线的夹角赋予α
               if(τxy!=0){
                itmp = (sqrt(intersection[0]*intersection[0] + intersection[1]*intersection[1] + intersection[2]*intersection[2])) * 1;
                itmpa = intersection[0] * 1;               
                α = acos(itmpa/itmp);
                shear_stress[ii] += τxy*(cos(κ) * cos(ψ) * sin(α) + sin(κ) * cos(ψ_2) * cos(α));    }     
                }            

                ii++;qm++;

            }//end of for ...

          // 下面一段程序计算基面滑移的最大分切应力
            if(number2[0]!=0)
            {
            shear_max=0;
            for(ii=0;ii<number2[0];ii++){
                shear_stress[ii] = shear_stress[ii] * k[0];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[0] = shear_max;
            }
        
          // 下面一段程序计算棱面滑移的最大分切应力   
            if(number2[1]!=0)
            {
            shear_max=0;
            for(ii=number2[0];ii<number2[0]+number2[1];ii++){
                shear_stress[ii] = shear_stress[ii] * k[1];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[1] = shear_max;}
            
            // 下面一段程序计算锥面滑移的最大分切应力
            if(number2[2]!=0)
            {
            shear_max=0;
            for(ii=number2[0]+number2[1];ii<number2[0]+number2[1]+number2[2];ii++){
                shear_stress[ii] = shear_stress[ii] * k[2];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[2] = shear_max;
            }
            
            // 下面一段程序计算{10-12}<-1011>孪晶系的最大分切应力
            
            if(number2[3]!=0)
            {
            shear_max=0;
            for(ii=number2[0]+number2[1]+number2[2];ii<number2[0]+number2[1]+number2[2]+number2[3];ii++){
                shear_stress[ii] = shear_stress[ii] * k[3];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[3] = shear_max;
            }
            
            // 下面一段程序计算{10-11}(10-12)孪晶系的最大分切应力
            if(number2[4]!=0)
            {
            shear_max=0;
            
            for(ii=number2[0]+number2[1]+number2[2]+number2[3];ii<number2[0]+number2[1]+number2[2]+number2[3]+number2[4];ii++){
                shear_stress[ii] = shear_stress[ii] * k[4];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[4] = shear_max;
                    }

          if(number2[5]!=0)
            {
            shear_max=0;
            
            for(ii=number2[0]+number2[1]+number2[2]+number2[3]+number2[4];ii<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5];ii++){
                shear_stress[ii] = shear_stress[ii] * k[5];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[5] = shear_max;

                        }


             if(number2[6]!=0)
            {
            shear_max=0;
            
            for(ii=number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5];ii<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6];ii++){
                shear_stress[ii] = shear_stress[ii] * k[6];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[6] = shear_max;
            }


             if(number2[7]!=0)
            {
            shear_max=0;
            
            for(ii=number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6];ii<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6]+number2[7];ii++){
                shear_stress[ii] = shear_stress[ii] * k[7];
                if(shear_stress[ii]>=shear_max){
                    shear_max=shear_stress[ii];
                }//end of if ...
            }//end of for ...
            schmid_max[7] = shear_max;
            }
            
            //下面一段程序计算所有滑移系中的最大分切应力
            shear_max=0;
            for(ii=0;ii<=4;ii++){
                if(schmid_max[ii]>=shear_max){
                    shear_max=schmid_max[ii];
                }//end of if ...
            }//end of for ...
            
           // 下面一段程序选择出分切应力最大的滑移系,将其赋予pt
            count=0;
            double mm=1000.0000;
            for(ii=0;ii<number;ii++)
                if(abs((shear_stress[ii]-shear_max)*mm)==0.0){
                    count++;
                    pt[count-1]=ii;
                }//end of if ...
                plane[0].H=400*plane[0].H;
                plane[0].K=400*plane[0].K;
        if(pt[0]>=0&&pt[0]<number2[0])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(255,0,0));            
            
        if(pt[0]>=number2[0]&&pt[0]<number2[0]+number2[1])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(0,0,255));

        if(pt[0]>=number2[0]+number2[1]&&pt[0]<number2[0]+number2[1]+number2[2])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(0,255,0));
            
        if(pt[0]>=number2[0]+number2[1]+number2[2]&&pt[0]<number2[0]+number2[1]+number2[2]+number2[3])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(255,255,0));
            
        if(pt[0]>=number2[0]+number2[1]+number2[2]+number2[3]&&pt[0]<number2[0]+number2[1]+number2[2]+number2[3]+number2[4])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(255,0,255));
        
        if(pt[0]>=number2[0]+number2[1]+number2[2]+number2[3]+number2[4]&&pt[0]<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(255,255,255));
        
        if(pt[0]>=number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]&&pt[0]<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(125,0,255));

        if(pt[0]>=number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6]&&pt[0]<number2[0]+number2[1]+number2[2]+number2[3]+number2[4]+number2[5]+number2[6]+number2[7])
                pDC->SetPixel((int)plane[0].K-700,(int)plane[0].H,RGB(255,0,125));

            
               
            
        }//end of for ...
        }//end of if           

搜索更多相关主题的帖子: 图形 如何 
2012-07-14 13:46
快速回复:如何能使绘制的图形转化为位图再呈现在屏幕上
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026601 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved