游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1006|回复: 0

请教:下面这段关于剪切板的程序,我看不懂,请各位大

[复制链接]

37

主题

67

帖子

73

积分

注册会员

Rank: 2

积分
73
发表于 2006-2-24 15:24:00 | 显示全部楼层 |阅读模式
//Directdraw 变量
LPDIRECTDRAW7         lpDDraw7    =NULL;       //Directdraw对象
LPDIRECTDRAWSURFACE7  lpDDprimary =NULL;       //Directdraw主画面
LPDIRECTDRAWSURFACE7  lpDDback    =NULL;       //Directdraw后备画面
LPDIRECTDRAWSURFACE7  lpDDbpic    =NULL;       //Directdraw备用画面
DDSURFACEDESC2        ddsd;                    //Directdraw表面描叙界面
DDBLTFX               ddbltfx;                 //Directdraw图形变换变量
LPDIRECTDRAWCLIPPER   lpDDclip    =NULL;       //Directdraw剪切板
BMPPIC                bitmap;                  //BMP 位图


/////////////////////////////////////////////
//DirectDraw剪切板
/////////////////////////////////////////////
LPDIRECTDRAWCLIPPER CreatDDClipper(LPDIRECTDRAWSURFACE7 lpDDraw,
                                                                   int Clipnumber,
                                                                   LPRECT clipsqe)
{

        int index;
        LPDIRECTDRAWCLIPPER lpDDtempclip; //Directdraw 剪切板
        LPRGNDATA  clipregion ;           //剪切区域序列

        //创建剪切板

        if (FAILED(lpDDraw7->CreateClipper(0,&lpDDtempclip,NULL)))
    {
                MessageBox(NULL,TEXT("DirectDraw Create clipper error!"),
                        TEXT("Wrong!"),MB_OK);
                return(NULL);
        }


        //定义剪切区
        clipregion = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+Clipnumber*sizeof(RECT));
        memcpy(clipregion->Buffer,clipsqe,sizeof(RECT)*Clipnumber);
        clipregion->rdh.dwSize          = sizeof(RGNDATAHEADER);
        clipregion->rdh.iType           = RDH_RECTANGLES;
        clipregion->rdh.nCount          = Clipnumber;
        clipregion->rdh.nRgnSize        = Clipnumber*sizeof(RECT);
        clipregion->rdh.rcBound.left    =  80000;
        clipregion->rdh.rcBound.top     =  80000;
        clipregion->rdh.rcBound.right   = -80000;
        clipregion->rdh.rcBound.bottom  = -80000;




        for (index=0; index<Clipnumber; index++)
    {
                if (clipsqe[index].left < clipregion->rdh.rcBound.left)
                        clipregion->rdh.rcBound.left = clipsqe[index].left;

                if (clipsqe[index].right > clipregion->rdh.rcBound.right)
                        clipregion->rdh.rcBound.right = clipsqe[index].right;

                if (clipsqe[index].top < clipregion->rdh.rcBound.top)
                        clipregion->rdh.rcBound.top = clipsqe[index].top;

                if (clipsqe[index].bottom > clipregion->rdh.rcBound.bottom)
                        clipregion->rdh.rcBound.bottom = clipsqe[index].bottom;
    }
       
        if (FAILED(lpDDtempclip->SetClipList(clipregion, 0)))
        {
                free(clipregion);
                return(NULL);
        }

        if (FAILED(lpDDraw->SetClipper(lpDDtempclip)))
        {
                free(clipregion);
                return(NULL);
        }

        free(clipregion);
        return(lpDDtempclip);
}


问题1:
//定义剪切区
clipregion = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+Clipnumber*sizeof(RECT));
memcpy(clipregion->Buffer,clipsqe,sizeof(RECT)*Clipnumber);
clipregion->rdh.dwSize          = sizeof(RGNDATAHEADER);
clipregion->rdh.iType           = RDH_RECTANGLES;
clipregion->rdh.nCount          = Clipnumber;
clipregion->rdh.nRgnSize        = Clipnumber*sizeof(RECT);
clipregion->rdh.rcBound.left    =  80000;
clipregion->rdh.rcBound.top     =  80000;
clipregion->rdh.rcBound.right   = -80000;
clipregion->rdh.rcBound.bottom  = -80000;

请教:
上面这段话是什么意思啊?

问题2:
for (index=0; index<Clipnumber; index++)
    {
                if (clipsqe[index].left < clipregion->rdh.rcBound.left)
                        clipregion->rdh.rcBound.left = clipsqe[index].left;

                if (clipsqe[index].right > clipregion->rdh.rcBound.right)
                        clipregion->rdh.rcBound.right = clipsqe[index].right;

                if (clipsqe[index].top < clipregion->rdh.rcBound.top)
                        clipregion->rdh.rcBound.top = clipsqe[index].top;

                if (clipsqe[index].bottom > clipregion->rdh.rcBound.bottom)
                        clipregion->rdh.rcBound.bottom = clipsqe[index].bottom;
    }

请教上面这段话是什么意思?

谢谢各位大大!
[em20] [em20] [em20] [em20]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 17:40

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表