標籤:class blog http ext com 類
在我理解看來,Graphics是一個device context和你的drawing conetent之間的一個中介。它儲存了device context的相關屬性,以及drawing content的屬性。這樣,它就能用自己的方法把drawing content“映射”到device content 之上。
GDI中的繪圖工作是直接在device context之上進行的。在GDI—+中,你因該在device context之上再建立一個graphics,然後調用graphics的相關方法完成繪圖等工作。
Graphics類有四個建構函式:
static Graphics* FromHDC(IN HDC hdc) { return new Graphics(hdc); } static Graphics* FromHDC(IN HDC hdc, IN HANDLE hdevice) { return new Graphics(hdc, hdevice); } static Graphics* FromHWND(IN HWND hwnd, IN BOOL icm = FALSE) { return new Graphics(hwnd, icm); } static Graphics* FromImage(IN Image *image) { return new Graphics(image); }
建構函式1從image對象建立一個Graphics類。這種方式允許你在開啟某張,或者產生某張,位元影像之後,應用Grapgics的方法對改位元影像進行操作。
建構函式2從一個傳統的HDC擷取一個Graphics對象,把傳統的在HDC完成的操作接手過來。
建構函式3允許你建立一個綁定於某個特定裝置的Graphics類執行個體。
建構函式4允許你直接從特定的視窗hwnd直接擷取一個Graphics類執行個體。
轉載地址:http://www.cppblog.com/dingding/archive/2008/06/27/54795.html