|
IImage接口打开宽或高是1个象素的图片后再打开其他图片不正常
[复制链接]
IImage接口打开宽或高是1个象素的图片后,再打开其他图片,用IImage相关的接口描画出来是之前打开的图片,有时还支离破碎的。
实机上的问题,模拟器上正常,是IImage的调用有问题还是OSImage做的有问题?
哪位达人遇到过请不吝赐教。
BOOL CImageStatic::ShowJPEG(HDC hdc,const TCHAR * filename,int nStartX,int nStartY,int nChangeX,int nChangeY)
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
ImageInfo imageInfo;
RECT dstRc;
BOOL bRet = FALSE;
HRESULT hr = S_OK;
CString str;
if (FAILED(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
str.Format(TEXT("CoInitializeEx failed!\n%s"), ErrStr(hr));
MessageBox(str);
goto ShowJPEG_End;
}
if (SUCCEEDED(hr = CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory)))
{
if (SUCCEEDED(hr = pImgFactory->CreateImageFromFile(filename, &pImage)))
{
if (FAILED(hr = pImage->GetImageInfo(&imageInfo))) {
str.Format(TEXT("GetImageInfo failed!\n%s"), ErrStr(hr));
MessageBox(str);
goto ShowJPEG_End;
}
dstRc.left = nStartX;
dstRc.top = nStartY;
dstRc.right = nStartX + nChangeX;
dstRc.bottom = nStartY + nChangeY;
if (FAILED(hr = pImage->Draw(hdc, &dstRc, NULL))) {
str.Format(TEXT("Draw failed!\n%s"), ErrStr(hr));
MessageBox(str);
goto ShowJPEG_End;
}
bRet = TRUE;
}
else {
str.Format(TEXT("CreateImageFromFile failed!\n%s"), ErrStr(hr));
MessageBox(str);
}
}
else {
str.Format(TEXT("CoCreateInstance failed!\n%s"), ErrStr(hr));
MessageBox(str);
}
ShowJPEG_End:
if (pImage) {
pImage->Release();
}
if (pImgFactory) {
pImgFactory->Release();
}
CoUninitialize();
return bRet;
}
|
|