第2个回答 2011-11-10
原型:
int WINAPI icePub_dispImg(HWND hWnd,char *strImgFilename,int x,int y)
输入:hWnd 窗体或控件句柄
strImgFilename 待显示的图片文件名
x x坐标
y y坐标
输出:
{
typedef int (WINAPI ICEPUB_DISPIMG)(HWND hWnd,char *strImgFilename,int x,int y);
ICEPUB_DISPIMG *icePub_dispImg = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
{
icePub_dispImg = (ICEPUB_DISPIMG *)GetProcAddress(hDLLDrv, "icePub_dispImg");
}
if(icePub_dispImg != NULL)
icePub_dispImg(m_hWnd,"b.png",10,10);
// icePub_dispImg(m_ctrlText.m_hWnd,"b.jpg",0,0);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
}本回答被提问者采纳
第3个回答 2011-11-11
BOOL OpenBMPFile(LPCSTR lpFileName, BITMAPINFO *pBmpInfo, BYTE *pImageBuffer)
{
BOOL bRVal = TRUE;
DWORD dwBytesRead = 0;
DWORD dwSize = 0;
BITMAPFILEHEADER bfh;
HANDLE hFile = ::CreateFile(lpFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (hFile == INVALID_HANDLE_VALUE) {
bRVal = FALSE;
}
else{
dwSize = sizeof(BITMAPFILEHEADER);
::ReadFile(hFile, &bfh, dwSize, &dwBytesRead, NULL );
if (bfh.bfType != ((WORD)'M' << 8 | 'B')) {
bRVal = FALSE;
}
else{
dwSize = sizeof(BITMAPINFOHEADER);
::ReadFile(hFile, pBmpInfo, dwSize, &dwBytesRead, NULL);
if (pBmpInfo->bmiHeader.biBitCount <= 8) {
dwSize = bfh.bfOffBits - sizeof(BITMAPFILEHEADER) - sizeof(BITMAPINFOHEADER);
ReadFile(hFile,
(char *)pBmpInfo + sizeof(BITMAPINFOHEADER),
dwSize,
&dwBytesRead,
NULL
);
}
dwSize = WIDTH_BYTES(pBmpInfo->bmiHeader.biWidth * pBmpInfo->bmiHeader.biBitCount) *
pBmpInfo->bmiHeader.biHeight;
ReadFile(hFile, pImageBuffer, dwSize, &dwBytesRead, NULL);
}
CloseHandle(hFile);
}
return bRVal;
}