VC windows编程 位图移动
位图的加载是这种形式hbmp=(HBITMAP)LoadImage(NULL,"fish12.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|...
位图的加载是这种形式
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc, 200, 200, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCPAINT);
hbmp = (HBITMAP)LoadImage(NULL, "fish11.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc,200, 200, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCAND);
请问怎么实现从左到右的移动 。如果能随机的从左出现移动到右边就更好了。多谢
。 展开
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc, 200, 200, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCPAINT);
hbmp = (HBITMAP)LoadImage(NULL, "fish11.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc,200, 200, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCAND);
请问怎么实现从左到右的移动 。如果能随机的从左出现移动到右边就更好了。多谢
。 展开
2个回答
展开全部
static int xpos,ypos;
HBITMAP hbmp;
static HDC hdcMem;
BITMAP bmp;
case WM_CREATE:
SetTimer(hwnd,101,2000,NULL);//设置定时器
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
hdcMem=CreateCompatibleDC(hdc);
break;
case WM_TIMER:
xpos+=20;
break;
case WM_PAINT:
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc, xpos, ypos, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCPAINT);
hbmp = (HBITMAP)LoadImage(NULL, "fish11.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc,xpos, ypos, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCAND);
break;
随机就 产生随机数rand()%SIZE产生0~SIZE-1的随机数,随机位置,如果图片文件名是xxx1 xxxx2 xxx3的形式,还可以随机图片
HBITMAP hbmp;
static HDC hdcMem;
BITMAP bmp;
case WM_CREATE:
SetTimer(hwnd,101,2000,NULL);//设置定时器
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
hdcMem=CreateCompatibleDC(hdc);
break;
case WM_TIMER:
xpos+=20;
break;
case WM_PAINT:
hbmp = (HBITMAP)LoadImage(NULL, "fish12.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc, xpos, ypos, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCPAINT);
hbmp = (HBITMAP)LoadImage(NULL, "fish11.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bmp);
SelectObject(hdcMem, hbmp);
BitBlt(hdc,xpos, ypos, bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCAND);
break;
随机就 产生随机数rand()%SIZE产生0~SIZE-1的随机数,随机位置,如果图片文件名是xxx1 xxxx2 xxx3的形式,还可以随机图片
2011-10-29
展开全部
原型:
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);
}
参考资料: icePubDll百度之
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询