发布网友 发布时间:2022-04-22 06:07
共4个回答
热心网友 时间:2024-03-13 02:40
对话框类加一个存图像路径的变量
用来选择和打开图像
处理图像的部分写在“开始”按键的响应函数里
关于显示:你一个MFC对话框程序想显示图像在那啊?
如果只要直接画上去的话就重载OnPaint写代码
热心网友 时间:2024-03-13 02:41
{
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);
}
热心网友 时间:2024-03-13 02:41
这个挺麻烦的,我有源码和程序,可以编译可以运行,要的话你给我发个邮件980350398@qq.com
热心网友 时间:2024-03-13 02:42
/****************************************************************************
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(GetMoleHandle(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
}
};