5个回答
展开全部
/****************************************************************************
CDrawBitmap封装了一些画图片的函数。
调用如下:
CDrawBitmap g_bmp1("D:\\My Documents\\My Pictures\\风景图片\\4244123431.bmp");
g_bmp1.Draw(m_hWnd);
CDrawBitmap g_bmp2("D:\\My Documents\\My Pictures\\风景图片\\plane.bmp");
g_bmp2.DrawTransparent(m_hWnd);
CDrawBitmap g_bmp3("D:\\My Documents\\My Pictures\\风景图片\\jzg2.bmp");
g_bmp3.DrawTransparent(m_hWnd);
****************************************************************************/
//使用TransparentBlt需要添加 #pragma comment(lib,"msimg32.lib")
#pragma comment(lib,"msimg32.lib")
class CDrawBitmap
{
private:
HBITMAP m_bitmap;
int m_bitmap_cx;
int m_bitmap_cy;
public:
CDrawBitmap() {}
CDrawBitmap(TCHAR * PicturePath) { LoadPicture(PicturePath); }
CDrawBitmap(WORD ResourceID) { LoadResource(ResourceID); }
~CDrawBitmap() { ::DeleteObject(m_bitmap);}
bool LoadPicture(TCHAR * PicturePath)
{
m_bitmap=(HBITMAP)LoadImage(NULL, //应用程序实例
PicturePath, //路径
IMAGE_BITMAP,
0, //如果不置0,则此参数指定m_bitmap的宽(位图被拉伸)
0, //如果不置0,则此参数指定m_bitmap的高(位图被拉伸)
LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
if (!m_bitmap)
return false;
BITMAP bmp;
GetObject(m_bitmap,sizeof(BITMAP),(LPSTR)&bmp);
m_bitmap_cx=bmp.bmWidth;
m_bitmap_cy=bmp.bmHeight;
return true;
}
bool LoadResource(WORD ResourceID)
{
m_bitmap=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE (ResourceID) );
if (!m_bitmap)
return false;
BITMAP bmp;
GetObject(m_bitmap,sizeof(BITMAP),(LPSTR)&bmp);
m_bitmap_cx=bmp.bmWidth;
m_bitmap_cy=bmp.bmHeight;
return true;
}
void Draw(HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
Draw(hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
void Draw(HDC hScrDC,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
BitBlt(hScrDC,x,y,width,height,hMemDC,0,0,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawTransparent(HWND hWnd=NULL,int x=0,int y=0)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawTransparent(hScrDC,x,y);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
//不进行拉伸处理,如需要,请自行修改代码TransparentBlt中的参数
//使用TransparentBlt需要添加 #pragma comment(lib,"msimg32.lib")
void DrawTransparent(HDC hScrDC,int x=0,int y=0,UINT crTransparent=RGB(255,255,255))
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
::TransparentBlt(hScrDC,x,y,m_bitmap_cx,m_bitmap_cy,hMemDC,0,0,m_bitmap_cx,m_bitmap_cy,crTransparent);
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawStretch(HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawStretch(hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
void DrawStretch(HDC hScrDC=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
SetStretchBltMode(hScrDC,COLORONCOLOR); //一定要先调用这个
StretchBlt(hScrDC,x,y,width,height,hMemDC,0,0,m_bitmap_cx,m_bitmap_cy,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
};
void DrawBitmap(HBITMAP m_bitmap,HDC hScrDC,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
BitBlt(hScrDC,x,y,width,height,hMemDC,0,0,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawBitmap(HBITMAP m_bitmap,HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawBitmap(m_bitmap,hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
CDrawBitmap封装了一些画图片的函数。
调用如下:
CDrawBitmap g_bmp1("D:\\My Documents\\My Pictures\\风景图片\\4244123431.bmp");
g_bmp1.Draw(m_hWnd);
CDrawBitmap g_bmp2("D:\\My Documents\\My Pictures\\风景图片\\plane.bmp");
g_bmp2.DrawTransparent(m_hWnd);
CDrawBitmap g_bmp3("D:\\My Documents\\My Pictures\\风景图片\\jzg2.bmp");
g_bmp3.DrawTransparent(m_hWnd);
****************************************************************************/
//使用TransparentBlt需要添加 #pragma comment(lib,"msimg32.lib")
#pragma comment(lib,"msimg32.lib")
class CDrawBitmap
{
private:
HBITMAP m_bitmap;
int m_bitmap_cx;
int m_bitmap_cy;
public:
CDrawBitmap() {}
CDrawBitmap(TCHAR * PicturePath) { LoadPicture(PicturePath); }
CDrawBitmap(WORD ResourceID) { LoadResource(ResourceID); }
~CDrawBitmap() { ::DeleteObject(m_bitmap);}
bool LoadPicture(TCHAR * PicturePath)
{
m_bitmap=(HBITMAP)LoadImage(NULL, //应用程序实例
PicturePath, //路径
IMAGE_BITMAP,
0, //如果不置0,则此参数指定m_bitmap的宽(位图被拉伸)
0, //如果不置0,则此参数指定m_bitmap的高(位图被拉伸)
LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
if (!m_bitmap)
return false;
BITMAP bmp;
GetObject(m_bitmap,sizeof(BITMAP),(LPSTR)&bmp);
m_bitmap_cx=bmp.bmWidth;
m_bitmap_cy=bmp.bmHeight;
return true;
}
bool LoadResource(WORD ResourceID)
{
m_bitmap=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE (ResourceID) );
if (!m_bitmap)
return false;
BITMAP bmp;
GetObject(m_bitmap,sizeof(BITMAP),(LPSTR)&bmp);
m_bitmap_cx=bmp.bmWidth;
m_bitmap_cy=bmp.bmHeight;
return true;
}
void Draw(HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
Draw(hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
void Draw(HDC hScrDC,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
BitBlt(hScrDC,x,y,width,height,hMemDC,0,0,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawTransparent(HWND hWnd=NULL,int x=0,int y=0)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawTransparent(hScrDC,x,y);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
//不进行拉伸处理,如需要,请自行修改代码TransparentBlt中的参数
//使用TransparentBlt需要添加 #pragma comment(lib,"msimg32.lib")
void DrawTransparent(HDC hScrDC,int x=0,int y=0,UINT crTransparent=RGB(255,255,255))
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
::TransparentBlt(hScrDC,x,y,m_bitmap_cx,m_bitmap_cy,hMemDC,0,0,m_bitmap_cx,m_bitmap_cy,crTransparent);
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawStretch(HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawStretch(hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
void DrawStretch(HDC hScrDC=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
SetStretchBltMode(hScrDC,COLORONCOLOR); //一定要先调用这个
StretchBlt(hScrDC,x,y,width,height,hMemDC,0,0,m_bitmap_cx,m_bitmap_cy,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
};
void DrawBitmap(HBITMAP m_bitmap,HDC hScrDC,int x=0,int y=0,int width=100,int height=100)
{
HDC hMemDC=CreateCompatibleDC(hScrDC); //创建内存DC
::SelectObject(hMemDC,m_bitmap); //把位图选进内存DC
BitBlt(hScrDC,x,y,width,height,hMemDC,0,0,SRCCOPY); //内存DC映射到屏幕DC
::DeleteDC(hMemDC) ; //删除内存DC
}
void DrawBitmap(HBITMAP m_bitmap,HWND hWnd=NULL,int x=0,int y=0,int width=100,int height=100)
{
HDC hScrDC=GetDC(hWnd); //创建屏幕DC
DrawBitmap(m_bitmap,hScrDC,x,y,width,height);
::ReleaseDC(hWnd,hScrDC) ; //释放屏幕DC
}
东莞大凡
2024-08-07 广告
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进...
点击进入详情页
本回答由东莞大凡提供
展开全部
使用loadimage函数加载bmp图片
LoadImage(hInst,"BVBB.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
使用BitBlt函数显示bmp图片
BitBlt(hDC,0,0,ClientRect.right,ClientRect.bottom,hMemDC,0,0,SRCCOPY);
-------------------------------------------------------------------------------------------------
if(m_hBitmap) //已经载入过位图
{
m_Bitmap.Detach();
DeleteObject(m_hBitmap);
m_hBitmap=NULL;
}
m_hBitmap=(HBITMAP)::LoadImage(NULL,lpszPathName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(m_hBitmap==NULL)
{
TRACE( "Load Bitmap Error ");
}
m_Bitmap.Attach(m_hBitmap);
LoadImage(hInst,"BVBB.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
使用BitBlt函数显示bmp图片
BitBlt(hDC,0,0,ClientRect.right,ClientRect.bottom,hMemDC,0,0,SRCCOPY);
-------------------------------------------------------------------------------------------------
if(m_hBitmap) //已经载入过位图
{
m_Bitmap.Detach();
DeleteObject(m_hBitmap);
m_hBitmap=NULL;
}
m_hBitmap=(HBITMAP)::LoadImage(NULL,lpszPathName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(m_hBitmap==NULL)
{
TRACE( "Load Bitmap Error ");
}
m_Bitmap.Attach(m_hBitmap);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用loadimage函数加载bmp图片
LoadImage(hInst,"BVBB.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
使用BitBlt函数显示bmp图片
BitBlt(hDC,0,0,ClientRect.right,ClientRect.bottom,hMemDC,0,0,SRCCOPY);
LoadImage(hInst,"BVBB.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
使用BitBlt函数显示bmp图片
BitBlt(hDC,0,0,ClientRect.right,ClientRect.bottom,hMemDC,0,0,SRCCOPY);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-11-26
展开全部
{
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.bmp",10,10);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
}
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.bmp",10,10);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主给我邮箱。我发份我写的源代码给你;
这个暑假我在做指纹识别;刚好研究了这个。
这个暑假我在做指纹识别;刚好研究了这个。
追问
hexingmin12@163.com
先谢谢你啊
追答
哈哈,这就发给你
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询