热门IT资讯网

VC中显示ICON和BMP图片

发表于:2024-11-28 作者:热门IT资讯网编辑
编辑最后更新 2024年11月28日,显示ICON图标,如下:static HICON hIcon = (HICON)::LoadImage( AfxGetInstanceHandle(), TEXT("1.ico

显示ICON图标,如下:

static HICON hIcon  = (HICON)::LoadImage(      AfxGetInstanceHandle(),       TEXT("1.ico"),      IMAGE_ICON,      0, 0,      LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE);        CClientDC dc(this);      dc.DrawIcon( 350,150,hIcon);

显示bmp位图,如下:

static HBITMAP hBitmap = (HBITMAP)::LoadImage(      NULL,       TEXT("1.bmp"),       IMAGE_BITMAP,       50, 50,       LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE);    CBitmap bmp;  bmp.m_hObject = hBitmap;    CDC memDC;//使用兼容位图DC  memDC.CreateCompatibleDC(GetDC());  memDC.SelectObject(bmp);    BITMAP bmpInfo;  bmp.GetBitmap(&bmpInfo);    bool ret = dc.BitBlt(350,200,bmpInfo.bmWidth,bmpInfo.bmHeight,&memDC,0,0,SRCCOPY);  //透明位图  //dc.TransparentBlt(350,200,bmpInfo.bmWidth,bmpInfo.bmHeight,&memDC,                     //0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,RGB(255,255,255));


0