且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

windows程序设设计(2) SDK贴图

更新时间:2022-08-13 08:05:44

下面是2个加载位图的函数 

HBITMAP LoadBitmap(

HINSTANCE hInstance,// handle to application instance   应用程序的句柄

LPCTSTR lpBitmapName // name of bitmap resource);    //位图资源的 ID 

这个函数可以夹杂一张位图并且返回 位图资源的 句柄 但是 推荐使用新的  LoadImage函数 这个函数可以从磁盘文件加载图片

 

HANDLE LoadImage(

HINSTANCE hinst, // handle to instance    handle

LPCTSTR lpszName,// image to load    要加载的图片

UINT uType, // image type   加载的图片类型

int cxDesired,// desired width    宽度 

int cyDesired,// desired height  高度

UINT fuLoad // load options);  加载选项  可以选择从LOADFROMFAILE  从文件加载 

 

 

 

BOOL BitBlt(

HDC hdcDest,// handle to destination DC   目的设备的DC

int nXDest, // x-coord of destination upper-left corner   目的DC的x

int nYDest, // y-coord of destination upper-left corner    y

 int nWidth,// width of destination rectangle   宽

int nHeight,// height of destination rectangle   高

HDC hdcSrc, // handle to source DC     源兼容DC

 int nXSrc, // x-coordinate of source upper-left corne

int nYSrc, // y-coordinate of source upper-left corner  

 DWORD dwRop // raster operation code);  操作方式

 

兼容DC 是GDI物件之一  可以利用 CreateCompatibleDC来创建 与 目的DC 相兼容的  DC  然后  我们利用 SeleteObject 将位图选到 兼容DC中

使用完了之后要DeleteObject删除

 

BitBlt 函数可以将兼容DC中的位图资源Copy到  目的DC   拷贝过程中设计到 WM_ERASEBKGND消息 喝 WM_PAINT消息的处理关系