这样显示出来的图片是倒着的,正反面颠倒,同时上下颠倒,很纳闷!
入门级低手,希望得到大家的帮忙,谢先!
//* OnDraw() 中的部分代码如下: IPicture *pPic;
IStream *pStm;
CFileStatus fstatus;
CFile file; LONG cb;
if(file.Open("test.jpg",CFile::modeRead)
&& file.GetStatus("test.jpg",fstatus)
&& ((cb = fstatus.m_size) != -1))
{
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);
LPVOID pvData = NULL;
if(hGlobal != NULL)
{
if((pvData = GlobalLock(hGlobal)) != NULL)
{
file.ReadHuge(pvData, cb);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,
TRUE,IID_IPicture,(LPVOID*)&pPic)))
{
OLE_XSIZE_HIMETRIC hmWidth;
OLE_YSIZE_HIMETRIC hmHeight;
pPic->get_Width(&hmWidth);
pPic->get_Height(&hmHeight); if(FAILED(pPic->Rende(*pDC,0,0,450,283,
0,0,hmWidth,hmHeight,NULL)))
{
AfxMessageBox("Failed To Render!");
pPic->Release();
}
}
else
{
AfxMessageBox("Error Loading Picture!");
}
}
}
else
{
AfxMessageBox("Can't Open Image File!");
}
}
入门级低手,希望得到大家的帮忙,谢先!
//* OnDraw() 中的部分代码如下: IPicture *pPic;
IStream *pStm;
CFileStatus fstatus;
CFile file; LONG cb;
if(file.Open("test.jpg",CFile::modeRead)
&& file.GetStatus("test.jpg",fstatus)
&& ((cb = fstatus.m_size) != -1))
{
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);
LPVOID pvData = NULL;
if(hGlobal != NULL)
{
if((pvData = GlobalLock(hGlobal)) != NULL)
{
file.ReadHuge(pvData, cb);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,
TRUE,IID_IPicture,(LPVOID*)&pPic)))
{
OLE_XSIZE_HIMETRIC hmWidth;
OLE_YSIZE_HIMETRIC hmHeight;
pPic->get_Width(&hmWidth);
pPic->get_Height(&hmHeight); if(FAILED(pPic->Rende(*pDC,0,0,450,283,
0,0,hmWidth,hmHeight,NULL)))
{
AfxMessageBox("Failed To Render!");
pPic->Release();
}
}
else
{
AfxMessageBox("Error Loading Picture!");
}
}
}
else
{
AfxMessageBox("Can't Open Image File!");
}
}
if(FAILED(pPic->Render(*pDC,0,0,450,283, 0,0,hmWidth,hmHeight,NULL)))
y轴由于是上小下大,所以图片翻了
对呀,没考虑坐标问题, 必定是把Y轴搞反了!
Render(*pDC,0,0,450,283, 0,hmHeight,hmWidth,-hmHeight,NULL) 我想这样,应该可行吧!
多谢指点!