|
在EVC下,IImage可以对PNG解码,可是为什么透明部分是白色?下面是代码。请问要怎么解决?还有没有其它的方法解决PNG在EVC下的显示问题?
hr = FindResource(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_PNG1), _T("PNG"));
dwsize = SizeofResource(GetModuleHandle(NULL),hr);
hg = LoadResource(GetModuleHandle(NULL),hr);
lp = (LPSTR)LockResource(hg);
pImageFactory = NULL;
pImage = NULL;
if(SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
HRESULT hResult = 0;
if(SUCCEEDED(hResult=CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void **)&pImageFactory)))
{
hResult = 0;
if(SUCCEEDED(hResult = (pImageFactory->CreateImageFromBuffer(lp,dwsize,DISPOSAL_NONE,&pImage))))
{
ImageInfo ImageInfo;
pImage->GetImageInfo(&ImageInfo);
pImage->Draw(hdc, CRect(0, 0, ImageInfo.Width,ImageInfo.Height),NULL); //显示图片
pImage->Release();
}
else
MessageBox(_T("CreateImageFromBuffer"),_T("error"), MB_OK | MB_ICONASTERISK );
pImageFactory->Release();
}
else
MessageBox(_T("CoCreateInstance"),_T("error"), MB_OK );
if (hResult == REGDB_E_CLASSNOTREG)
MessageBox(_T("REGDB_E_CLASSNOTREG"),_T("error"), MB_OK );
CoUninitialize();
}
DeleteObject(hr);
|
|