void pictureinpicture( )
{
………………………..
CBitmap bitmap,*oldmap;
pData1=(BYTE*)new char[biWidth*biHeight *3];//biWidth和biHeight为视频采集卡获取//的图像尺寸。
Read(pData1,bih.biWidth*bih.biHeight *3);//该函数从采集卡中获取数据
CClientDC dc(this);
m_pBMI1= new BITMAPINFO;//自定义的BMP文件信息结构,用于后面的图像显示
m_pBMI1->bmiHeader.biBitCount=24;
m_pBMI1->bmiHeader.biClrImportant=0;
m_pBMI1->bmiHeader.biClrUsed=0;
m_pBMI1->bmiHeader.biCompression=0;
m_pBMI1->bmiHeader.biHeight=biHeight;
m_pBMI1->bmiHeader.biPlanes=1;
m_pBMI1->bmiHeader.biSize=40;
m_pBMI1->bmiHeader.biSizeImage=WIDTHBYTES(biWidth*8)*biHeight*3;
m_pBMI1->bmiHeader.biWidth=biWidth;
m_pBMI1->bmiHeader.biXPelsPerMeter=0;
m_pBMI1->bmiHeader.biYPelsPerMeter=0;
////////////////////////////////////////////////////////////////////////
pData2=(BYTE*)new char[biWidth1*biHeight1 *3];//申请存放小图像的缓冲区
Read(pData2,biWidth1*biHeight1 *3);////向该缓冲区读数据
m_pBMI2= new BITMAPINFO;
m_pBMI2->bmiHeader.biBitCount=24;
m_pBMI2->bmiHeader.biClrImportant=0;
m_pBMI2->bmiHeader.biClrUsed=0;
m_pBMI2->bmiHeader.biCompression=0;
m_pBMI2->bmiHeader.biHeight=biHeight1;
m_pBMI2->bmiHeader.biPlanes=1;
m_pBMI2->bmiHeader.biSize=40;
m_pBMI2->bmiHeader.biSizeImage=WIDTHBYTES(biWidth1*8)*biHeight1*3;
m_pBMI2->bmiHeader.biWidth=biWidth1;
m_pBMI2->bmiHeader.biXPelsPerMeter=0;
m_pBMI2->bmiHeader.biYPelsPerMeter=0;
//下面实现画中画的显示
CDC MemDc;
MemDc.CreateCompatibleDC(&dc);
bitmap.CreateCompatibleBitmap(&dc,biWidth,biHeight);
oldmap=MemDc.SelectObject(&bitmap);
::StretchDIBits(MemDc.m_hDC,0,0,biWidth,biHeight,0,0,—biWidth,biHeight,pData1,m_pBMI1,DIB_RGB_COLORS,SRCCOPY);//首先将大图像画在内寸上下文中
::StretchDIBits(MemDc.m_hDC,20,20,biWidth1,biHeight1,_
0,0,biWidth1,biHeight1,pData2,m_pBMI2,DIB_RGB_COLORS,SRCCOPY);//再将小图像画在内寸上下文中
::StretchBlt(dc.m_hDC,0,0,bih.biWidth,bih.biHeight,_
MemDc.m_hDC,0,0,bih.biWidth,bih.biHeight,SRCCOPY);//将结果显示在屏幕上。
MemDc.SelectObject(oldmap);
delete pData1;
delete m_pBMI1;
delete pData2;
delete m_pBMI2;
}
|