windows mobile 根据Buffer中的图片数据进行图片呈现的方法.
data:buffer中的图片数据
size:buffer中的图片数据的大小
IImagingFactory *pImgFac;
IImage *pImage;
ImageInfo info;
if(SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void **)&pImgFac)))
{
if(SUCCEEDED(pImgFac->CreateImageFromBuffer(data,size,BufferDisposalFlagNone ,&pImage)))
{
pImage->GetImageInfo(&info);
HDC hdc=::GetDC(NULL);
HDC hMemdc=::CreateCompatibleDC(hdc);
HBITMAP hImg=::CreateCompatibleBitmap(hdc,info.Width,info.Height);
::SelectObject(hMemdc,hImg);
RECT rect = { 0 , 0 , info.Width,info.Height};
pImage -> Draw(hMemdc, &rect,NULL);
::DeleteDC(hMemdc);
::DeleteDC(hdc);
pImage->Release();
}
pImgFac->Release();
}