图片对称
void CMy1View::OnDraw(CDC* pDC)
{
CMy1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x,y,width,height,i;
//设置反面显示位图的起点和大小
//可以在别的地方设置,赋值
x=350; y=30; width=240; height=200;
BITMAP m_bm; CDC Dc;
if(Dc.CreateCompatibleDC(pDC)==FALSE) AfxMessageBox("Can't create DC");
// 选入位图
Dc.SelectObject(bitmap);
GetObject(bitmap, sizeof(BITMAP), (LPSTR)&m_bm);
//显示位图宽高
POINT ptSize;
// 取得位图的宽度
ptSize.x = m_bm.bmWidth;
// 取得位图的该度
ptSize.y = m_bm.bmHeight;
//显示正面位图
pDC->StretchBlt(10,30,240,200,&Dc,0,0,ptSize.x,ptSize.y,SRCCOPY);
//显示反面位图
//以下参数的说明:
//x+(i*w idth/ptSize.x)表示每个循环的起点位置,
//其中 w idth/ptSize.x 表示每次移动的大小
//y 为显示的 top
//height 为显示位图的高度
//ptSize.x-i 为每次 SRCCOPY 的起点 x
//在不同位置显示位图
for( i=0;i<ptSize.x;i++)
pDC->StretchBlt(x+(i*width/ptSize.x),y,width/ptSize.x,height,&Dc,ptSize.x-i,0,1,ptSize.y,SRCCOPY);
}
这里边bitmap没有定义,我是不是应该把它定义为CBitmap类型。如果不是应该定义为什么。