hbitmap是bitmap的指標,
msdn中:handle to a bitmap.typedef handle hbitmap;
cbitmap是mfc中封裝bitmap的類;
msdn中:encapsulates(囊括) a windows graphics device inte***ce (gdi)bitmap and provides member functions to manipulate(操作) the bitmap.
class cbitmap : public cgdiobject
轉化方法兩種,attach和fromhandle:
1cbitmap bmp;
2bmp.loadbitmap(idb_bitmap1);
3hbitmap hbm
=(hbitmap)bmp;
4cbitmap bmp1;
5bmp1.attach(hbm);67
hbitmap
=cbitmap.m_hobject
8cbitmap*=
cbitmap.fromhandle(hbitmap)910
//已知hbitmap hbit;
11cbitmap cb;
12cb.fromhandle(hbit);
1314
//已知cbitmap cb;
15hbitmap hbit
=(hbitmap)cb;
1617
cbitmap bmp;
18hbitmap hbmp;
19//
相互轉換:
20hbmp
=(hbitmap)bmp.getsafehandle();
21bmp.attach(hbmp);
注意點:
attach和fromhandle的區別
fromhandle得到的指標是臨時變數,
,通過attach連線的控制代碼可以長久保留,但通過fromhandle得到的只是暫時的,
大概只在乙個訊息區間內有效,很快便會被刪除,所以基本上不能用。
我用了fromhandle然後一直出錯!!!
HBITMAP和CBitmap的互相轉換
hbitmap hbmp 方法 cpp view plain copy cbitmap pbmp cbitmap fromhandle hbmp 方法 cpp view plain copy cbitmap bmp bmp.attach hbmp 方法 轉換出來的臨時cbitmap物件似乎並不是可靠...
CBitmap和HBITMAP的區別及相互轉換方法
cbitmap和hbitmap的區別及相互轉換方法 2008 06 16 08 05 03 cbitmap和hbitmap的區別及相互轉換方法 hpen hpen,hpen2 cpen pen,pen2 pen.attach hpen hpen2 hpen pen cbitmap bmp bmp.l...
Bitmap到CBitmap的轉換
bitmap tpbitmap new bitmap width,height,pixelformat24bpprgb hbitmap aaa1 bitmap bm tpbitmap gethbitmap color 0,0,0 aaa1 cbitmap pbm cbitmap fromhandle...