共有回帖数 1 个
-
-
m_pRecBMPSocket-Send(MSGTYPE1,30);
int ret=m_pRecBMPSocket-Receive(BTMInfoBuf,sizeof(BITMAP));
if (ret!=24)
{ MessageBox("failed recive 24"); return;}
BITMAP *BTMBUF=(BITMAP *)BTMInfoBuf;
btm.bmBits=BTMBUF-bmBits;
btm.bmBitsPixel=BTMBUF-bmBitsPixel;
btm.bmHeight=BTMBUF-bmHeight;
btm.bmPlanes=BTMBUF-bmPlanes;
btm.bmType=BTMBUF-bmType;
btm.bmWidth=BTMBUF-bmWidth;
btm.bmWidthBytes=BTMBUF-bmWidthBytes;
char MSGTYPE2[30]="D";
m_pRecBMPSocket-Send(MSGTYPE2,30);
int size=btm.bmWidthBytes*btm.bmHeight;
lpData=new char[size];
if(lpData==NULL)
MessageBox("faile memery");
char *pch=lpData ;
int nBytesRec=0;
int nBytesThisTime;
do{ //发送的内容较大采用循环发送完成为止
nBytesThisTime=m_pRecBMPSocket-Receive(pch,size-nBytesRec);
nBytesRec+=nBytesThisTime;
pch+=nBytesThisTime;
}while(nBytesRecUpdateAllViews(NULL,NULL,NULL);//更新视图
/////////////////////////////////////
}
void CClientView::OnDraw(CDC* pDC)
{//显示接收到的位图信息
CDocument* pDoc = GetDocument();
// TODO: add draw code here
if(lpData==NULL) return;
BITMAP myBITMAP;
myBITMAP.bmBits=btm.bmBits;
myBITMAP.bmBitsPixel=btm.bmBitsPixel;
myBITMAP.bmHeight=btm.bmHeight;
myBITMAP.bmPlanes=btm.bmPlanes;
myBITMAP.bmType=btm.bmType;
myBITMAP.bmWidth=btm.bmWidth;
myBITMAP.bmWidthBytes=btm.bmWidthBytes;
BITMAPINFOHEADER bih;
bih.biBitCount=myBITMAP.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=myBITMAP.bmHeight;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=myBITMAP.bmWidthBytes*myBITMAP.bmHeight;
bih.biWidth=myBITMAP.bmWidth;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
/////////////////////////
CBitmap tbitmap;
if(tbitmap.CreateBitmapIndirect(&myBITMAP)==NULL)
MessageBox("b mull");
if(tbitmap.m_hObject==NULL)MessageBox("
// CPaintDC tdc(this);
CDC tmemdc;
tmemdc.CreateCompatibleDC(pDC);
SetDIBits(tmemdc.m_hDC,tbitmap,0,btm.bmHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
CRect trect;
GetClientRect(&trect);
CBitmap* lpOldbit=tmemdc.SelectObject(&tbitmap);
pDC-StretchBlt(0,0,trect.Width(),trect.Height(),
&tmemdc,0,0,myBITMAP.bmWidth,
myBITMAP.bmHeight,SRCCOPY);
}
1楼 2016-07-28 11:27 回复
Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
意见反馈 |
关于直线 |
版权声明 |
会员须知