[ 2006/01/10 06:47 | by turbozv ]
|
Windows Mobile 5.0 终于有了IPicture接口了:) 可以很方便的显示BMP/WBMP/JPG/GIF/PNG图片。
另外如果需要获取图片大小,使用函数
void DrawImage(HDC hdc, const WCHAR * filename)
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
RECT rc;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory))) {
if (SUCCEEDED(pImgFactory->CreateImageFromFile(filename, &pImage))) {
pImage->Draw(hdc, &rc, NULL);
pImage->Release();
}
pImgFactory->Release();
}
CoUninitialize();
}
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
RECT rc;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory))) {
if (SUCCEEDED(pImgFactory->CreateImageFromFile(filename, &pImage))) {
pImage->Draw(hdc, &rc, NULL);
pImage->Release();
}
pImgFactory->Release();
}
CoUninitialize();
}
void DrawImage(HDC hdc, const VOID * buf, UINT size)
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
RECT rc;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory))) {
if (SUCCEEDED
(pImgFactory->
CreateImageFromBuffer(buf, size, DISPOSAL_NONE, &pImage))) {
pImage->Draw(hdc, &rc, NULL);
pImage->Release();
}
pImgFactory->Release();
}
CoUninitialize();
}
{
IImagingFactory *pImgFactory = NULL;
IImage *pImage = NULL;
RECT rc;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **) &pImgFactory))) {
if (SUCCEEDED
(pImgFactory->
CreateImageFromBuffer(buf, size, DISPOSAL_NONE, &pImage))) {
pImage->Draw(hdc, &rc, NULL);
pImage->Release();
}
pImgFactory->Release();
}
CoUninitialize();
}
另外如果需要获取图片大小,使用函数
ImageInfo imageInfo;
pImage->GetImageInfo(&imageInfo);
pImage->GetImageInfo(&imageInfo);
这个接口是不支持WBMP的,GIF也只能显示一帧。
搞错了,应该称你为99级的师兄了,还一直以为你是2K级的,记得以前你以前一直在管理BBS的,现在都没权限发帖子了,唉...