|
/**
*************************************************************
* 函 数 名: ShowPic
* 描 述: 在HDC上上显示对应路径下图片
* 输入参数: hdc:窗口设备句柄
filename:完整路径
nStartX:图片起始坐标X
nStartY:图片起始坐标Y
nChangeX:图片宽
nChangeY:图片高
* 输出参数: 无
* 返 回 值: 成功返回TRUE,失败返回FALSE
* 创 建 人: pc
* 日 期: 2006/11/28
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************/
BOOL ShowPic(HDC hdc,const TCHAR * filename,int nStartX,int nStartY,int nChangeX,int nChangeY)
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
ImageInfo imageInfo;
RECT dstRc;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory)))
{
if (SUCCEEDED(pImgFactory->CreateImageFromFile(filename, &pImage)))
{
pImage->GetImageInfo(&imageInfo);
dstRc.left = nStartX;
dstRc.top = nStartY;
dstRc.right = nStartX + nChangeX;
dstRc.bottom = nStartY + nChangeY;
pImage->Draw(hdc, &dstRc, NULL);
pImage->Release();
}
else
{
pImgFactory = NULL;
pImage = NULL;
CoUninitialize();
return FALSE;
}
}
else
{
pImgFactory = NULL;
pImage = NULL;
CoUninitialize();
return FALSE;
}
pImgFactory = NULL;
pImage = NULL;
CoUninitialize();
return TRUE;
} |
|