|
From: sgliu on 4 May 2008 23:27 ����IPicture�ӿ�����Ļ����ʾJPGͼƬ,����IPicture::Render����ʾͼƬ��ijһ����,����������ʾ��. �������ʾ���������ӡ���ӡ.�ɴ�ӡ���������ʾ�������кܴ���,����Ϊ:��ӡ�IJ��ֺ���ʾ�������Լ���С�����Ǻ�, �Ҹ���ô��? ����Ҫ��ӡ��Ļ��ʾ������. лл. ��������: void CPrintMAP2View::OnDraw(CDC* pDC) { CPrintMAP2Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; double lon=105.0; double lat=35.0; double mag=5.0; draw("",pDC,lon,lat,mag); } .... ... bool CPrintMAP2View::draw(char* sfn,CDC* pDC,double& lon,double& lat,double& mag) { IStream *pStm; CFileStatus fstatus; CFile file; LONG cb; CString m_Path("map\\china.bmp"); if (file.Open(m_Path,CFile::modeRead)&&file.GetStatus(m_Path,fstatus)&& ((cb = static_cast<LONG>(fstatus.m_size)) != -1)) { HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb); LPVOID pvData = NULL; if (hGlobal != NULL) { if ((pvData = GlobalLock(hGlobal)) != NULL) { file.Read(pvData, cb); GlobalUnlock(hGlobal); CreateStreamOnHGlobal(hGlobal, TRUE, &pStm); } } } file.Close(); IPicture *pPic; if(SUCCEEDED(OleLoadPicture(pStm,static_cast<LONG>(fstatus.m_size),TRUE,IID_IPicture,(LPVOID*)&pPic))) { OLE_XSIZE_HIMETRIC hmWidth; OLE_YSIZE_HIMETRIC hmHeight; pPic->get_Width(&hmWidth); //��� ��λ0.01���� pPic->get_Height(&hmHeight); //�߶� ��λ0.01���� double fX,fY; fX = pDC->GetDeviceCaps(HORZRES); //��ʾ��ȣ����أ� fY = pDC->GetDeviceCaps(VERTRES); //��ʾ�߶ȣ����أ� CSize size(hmWidth,hmHeight); pDC->HIMETRICtoLP(&size); // ת��MM_HIMETRICģʽ��λΪMM_TEXT���ص�λ CSize lefttop( LEFTSPACE , TOPSPACE ); pDC->LPtoHIMETRIC(&lefttop); CSize inlen( MAPLEN - LEFTSPACE - RIGHTSPACE , MAPWIDTH - TOPSPACE -BOTTOMSPACE ); pDC->LPtoHIMETRIC(&inlen); double lonspan = RIGHTLON - LEFTLON ; double latspan = TOPLAT - BOTTOMLAT ; double perlon = inlen.cx/lonspan; double perlat = inlen.cy/latspan; OLE_XPOS_HIMETRIC x0 = static_cast<OLE_XPOS_HIMETRIC>(( lon - LEFTLON ) *perlon + lefttop.cx); OLE_XPOS_HIMETRIC y0 = ( TOPLAT - lat ) * perlat + lefttop.cy; OLE_XPOS_HIMETRIC temx=3049; CSize epic(temx,y0); pDC->LPtoHIMETRIC(&epic); y0=epic.cy; //��ӡ������� OLE_XPOS_HIMETRIC x1 = x0 - perlon * 3; //��ʼ���X OLE_XPOS_HIMETRIC y1 = y0 - perlat * 2; //��ʼ���Y OLE_XPOS_HIMETRIC xlen = 6 * perlon; //���ȷ�Χ OLE_XPOS_HIMETRIC ylen = 4 * perlat; //���γ�ȷ�Χ if(FAILED(pPic->Render(pDC->m_hDC,100,100,fX-200,fY-200,x1,hmHeight-y1,xlen,-ylen,NULL))) AfxMessageBox("��Ⱦͼ��ʧ�ܣ�"); //================================================================= // �����У����й̶�Ϊ����������� int radius; if(mag < 4) radius = 10; else if(mag < 6) radius = 15; else if(mag < 7) radius = 20; else radius = 25; CBrush currbrush(RGB(255,0,0)); CBrush* pOldbrush=pDC->SelectObject(&currbrush); pDC->Ellipse(fX/2-radius,fY/2-radius,fX/2+radius,fY/2+radius); pDC->SelectObject(pOldbrush); //================================================================= pPic->Release(); } else AfxMessageBox("������װ��ͼ��ʧ�ܣ�"); return true;}
From: Joseph M. Newcomer on 5 May 2008 02:22 Your message has been fairly badly trashed. There isn't much to say here. joe On Mon, 5 May 2008 11:27:16 +0800, "sgliu" <sgliu(a)eq-he.ac.cn> wrote: >����IPicture�ӿ�����Ļ����ʾJPGͼƬ,����IPicture::Render����ʾͼƬ��ijһ����,����������ʾ��. >�������ʾ���������ӡ���ӡ.�ɴ�ӡ���������ʾ�������кܴ���,����Ϊ:��ӡ�IJ��ֺ���ʾ�������Լ���С�����Ǻ�, >�Ҹ���ô��? >����Ҫ��ӡ��Ļ��ʾ������. >лл. > >��������: >void CPrintMAP2View::OnDraw(CDC* pDC) >{ > CPrintMAP2Doc* pDoc = GetDocument(); > ASSERT_VALID(pDoc); > if (!pDoc) > return; > > double lon=105.0; > double lat=35.0; > double mag=5.0; > draw("",pDC,lon,lat,mag); >} >... ... > >bool CPrintMAP2View::draw(char* sfn,CDC* pDC,double& lon,double& lat,double& >mag) >{ > IStream *pStm; > CFileStatus fstatus; > CFile file; > LONG cb; > CString m_Path("map\\china.bmp"); > if (file.Open(m_Path,CFile::modeRead)&&file.GetStatus(m_Path,fstatus)&& >((cb = static_cast<LONG>(fstatus.m_size)) != -1)) > { > HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb); > LPVOID pvData = NULL; > if (hGlobal != NULL) > { > if ((pvData = GlobalLock(hGlobal)) != NULL) > { > file.Read(pvData, cb); > GlobalUnlock(hGlobal); > CreateStreamOnHGlobal(hGlobal, TRUE, &pStm); > } > } > } > file.Close(); > > IPicture *pPic; > if(SUCCEEDED(OleLoadPicture(pStm,static_cast<LONG>(fstatus.m_size),TRUE,IID_IPicture,(LPVOID*)&pPic))) { OLE_XSIZE_HIMETRIC hmWidth; OLE_YSIZE_HIMETRIC hmHeight; pPic->get_Width(&hmWidth); //��� ��λ0.01���� pPic->get_Height(&hmHeight); //�߶� ��λ0.01���� double fX,fY; fX = pDC->GetDeviceCaps(HORZRES); //��ʾ��ȣ����أ� fY = pDC->GetDeviceCaps(VERTRES); //��ʾ�߶ȣ����أ� CSize size(hmWidth,hmHeight); pDC->HIMETRICtoLP(&size); // ת��MM_HIMETRICģʽ��λΪMM_TEXT���ص�λ CSize lefttop( LEFTSPACE , TOPSPACE ); pDC->LPtoHIMETRIC(&lefttop); CSize inlen( MAPLEN - LEFTSPACE - RIGHTSPACE , MAPWIDTH - TOPSPACE -BOTTOMSPACE ); pDC->LPtoHIMETRIC(&inlen); double lonspan = RIGHTLON - LEFTLON ; double latspan = TOPLAT - BOTTOMLAT ; double perlon = inlen.cx/lonspan; double perlat = inlen.cy/latspan; OLE_XPOS_HIMETRIC x0 = static_cast<OLE_XPOS_HIMETRIC>(( lon - LEFTLON ) *perlon + lefttop.cx); OLE_XPOS_HIMETRIC y0 = ( TOPLAT - lat ) * perlat + lefttop.cy; >OLE_XPOS_HIMETRIC temx=3049; CSize epic(temx,y0); pDC->LPtoHIMETRIC(&epic); y0=epic.cy; //��ӡ������� OLE_XPOS_HIMETRIC x1 = x0 - perlon * 3; //��ʼ���X OLE_XPOS_HIMETRIC y1 = y0 - perlat * 2; //��ʼ���Y OLE_XPOS_HIMETRIC xlen = 6 * perlon; //���ȷ�Χ OLE_XPOS_HIMETRIC ylen = 4 * perlat; //���γ�ȷ�Χ if(FAILED(pPic->Render(pDC->m_hDC,100,100,fX-200,fY-200,x1,hmHeight-y1,xlen,-ylen,NULL))) AfxMessageBox("��Ⱦͼ��ʧ�ܣ�"); //================================================================= // �����У����й̶�Ϊ����������� int radius; if(mag < 4) radius = 10; else if(mag < 6) radius = 15; else if(mag < 7) radius = 20; else radius = 25; CBrush currbrush(RGB(255,0,0)); CBrush* pOldbrush=pDC->SelectObject(&currbrush); pDC->Ellipse(fX/2-radius,fY/2-radius,fX/2+radius,fY/2+radius); pDC->SelectObject(pOldbrush); //================================================================= pPic->Release(); } else AfxMessageBox("������װ��ͼ��ʧ�ܣ�"); return >true;} Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: Trap MaxText trigger Next: How to do a function, like quick format? |