如何在VC中打开并读取一个位图文件?
4个回答
展开全部
点insert->rasourse->Bitmap
然后就会有一个Bitmap的对象被创建,记住它的标示号 一般是IDB_BITMAP1
然后用LoadBitmap( IDB_BITMAP1);
就能打开了
然后就会有一个Bitmap的对象被创建,记住它的标示号 一般是IDB_BITMAP1
然后用LoadBitmap( IDB_BITMAP1);
就能打开了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
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);
}
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);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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;
}
{
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;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问得太笼统了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询