|
//DrawImage 函数显示图片
void DrawImage(HDC hdc,const void *buffer,UINT size,LPCRECT rect)
{
IImageFactory *pImageFactory=NULL;
IImage *pImage=NULL;
CoInitializeEx(NULL,COINIT_MULTITHREADED);
if(SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void**)&pImageFactory)))
{
if(SUCCEEDED(pImageFactory->CreateImageFromBuffer(buffer,size,DISPOSAL_NONE,&pImage)))
{
pImage->Draw(hdc,rect,NULL);
pImage->Release();
}
pImageFactory->Release();
}
CoUninitialize();
}
//LoadResourceImage函数主要将图片导入内存,使用这个函数,只要将图片的ID,图片的类名,以及要显示图片的坐标位置输入即可.
void LoaResourceImage(HWND hwnd,LPCWSTR lpName,LPCWSTR lpType,int i,int left,int right,int bottom,int top)
{
HDC hdc;
HRSRC hr;
DWORD dwsize;
HGLOBAL hg;
LPSTR lp;
HMODULE hModule_Current=GetModuleHandle(NULL);
hr=FindResource(hModule_Current,lpName,lpType);
dwsize=SizeofResource(GetModuleHandle(NULL),hr);
lp=(LPSTR)LockResource(hg);
hdc=GetDC(hwnd);
RECT rect;
rect.bottom = bottom;
rect.top = top;
rect.right = right;
rect.left = left;
DrawImage(hdc,lp,dwsize,&rect);
DeleteObject(hr);
}
这里的IImage 和 IImageFactory类 在WINCE 5.0中是不是没有呢 |
|