研究好久才弄好,註釋的比較詳細,不明白的函數可以參考MSDN
bool TransparentDIB(CBitmap * dib, /*要繪製的位圖*/ CDC * pDC, /*目標DC*/ CRect * rct, /*目標矩形*/ COLORREF transColor, /*透明色*/ bool bStretch /*是否拉伸位圖以適應目標矩形*/) { //驗證參數 if(dib == NULL || pDC == NULL || rct == NULL) return false; int nWidth; int nHeight; //位圖信息對象 BITMAP w_bitmap_info; //獲取位圖信息 dib->GetBitmap(&w_bitmap_info); //新建設備上下文 CDC w_memoryDC; //創建兼容內存DC w_memoryDC.CreateCompatibleDC(pDC); //根據拉伸狀態獲得圖像實際繪製尺寸 if(bStretch) { nWidth = rct->Width(); nHeight = rct->Height(); } else { nWidth = w_bitmap_info.bmWidth; nHeight = w_bitmap_info.bmHeight; } w_memoryDC.SelectObject(dib);//選入位圖對象 w_memoryDC.SetBkColor(transColor);//設置透明色 CDC w_maskDC;//創建兼容內存DC作爲掩碼DC w_maskDC.CreateCompatibleDC(pDC);//創建兼容內存DC作爲掩碼DC CBitmap w_maskBitmap;//創建新位圖作爲掩碼位圖 w_maskBitmap.CreateBitmap(w_bitmap_info.bmWidth,w_bitmap_info.bmHeight,1,1,NULL); //創建新位圖作爲掩碼位圖 w_maskDC.SelectObject(&w_maskBitmap);//選入掩碼位圖 w_maskDC.BitBlt(0,0,w_bitmap_info.bmWidth,w_bitmap_info.bmHeight,&w_memoryDC,0,0,SRCCOPY); //SRCCOPY方式將源位圖以原始大小繪製到掩碼DC pDC->StretchBlt(0,0,nWidth,nHeight,&w_memoryDC,0,0,w_bitmap_info.bmWidth,w_bitmap_info.bmHeight,SRCINVERT); //SRCINVERT方式將源位圖拉伸繪製到窗口DC pDC->StretchBlt(0,0,nWidth,nHeight,&w_maskDC,0,0,w_bitmap_info.bmWidth,w_bitmap_info.bmHeight,SRCAND); //SRCAND方式將掩碼位圖拉伸繪製到窗口DC pDC->StretchBlt(0,0,nWidth,nHeight,&w_memoryDC,0,0,w_bitmap_info.bmWidth,w_bitmap_info.bmHeight,SRCINVERT); //SRCINVERT方式將源位圖拉伸繪製到窗口DC //完成繪製 w_memoryDC.DeleteDC();//刪除內存DC w_maskDC.DeleteDC();//刪除掩碼DC return true; }
前言 今天大姚給大家分享一款基於C#、WPF、Prism、MaterialDesign、HandyControl開發的通訊調試工具(支持Modbus RTU、MQTT調試,界面色彩豐富):Wu.CommTool。 工具特點 工具界面色彩豐
Linux/Golang/glibC系統調用 本文主要通過分析Linux環境下Golang的系統調用,以此闡明整個流程 有時候涉略過多,反而遭到質疑~,寫點文章證明自己實力也好 Golang系統調用 找個函數來分析 https://pk
也就是算出絕對路徑傳進去. import os wenjian='/'.join(os.path.abspath(__file__).split('/')[:-2])+'/' with open(wenjian+"meddata.jso
本週刊由 Python貓 出品,精心篩選國內外的 250+ 信息源,爲你挑選最值得分享的文章、教程、開源項目、軟件工具、播客和視頻、熱門話題等內容。願景:幫助所有讀者精進 Python 技術,並增長職業和副業的收入。 本期週刊分享了 12
當程序需要引用尚未定義的變量或標號時,編譯器會如何處理呢,這就涉及到向前引用(Forward Reference)的概念。 一、Forward Reference的概念 程序引用到之前尚未定義的變量(Variable)、標號(L
Offset僞指令我一直都認爲只是獲取標識符在段中的偏移地址,但經研究,發現了部分違反直覺的細微區別: 1、在完整端聲明(Full segment definition)的模式下 如果offset mygroup:myvar或o
之前有實現Q-Learning走迷宮,本篇實現SARSA走迷宮。 Q-Learning是一種off-policy算法,當前步採取的決策action不直接作用於環境生成下一次state,而是選擇最優的獎勵來更新Q表。 更新公式: SARSA
A script is a small piece of program that can add interactivity to our websites. For example, a script could generate a
The HTML Layouts specifies the arrangement of components on an HTML web page. A good layout structure of the webpage i
What is a HTML Favicon? A favicon is a small image that represents your website and helps users identify it among mult
The Layout Elements of HTML In HTML, there are various semantic elements that are used to define different parts of a
Now we all have learned various techniques to design an HTML layout including tables and semantic elements. We are ver
cs01 CSS Syntax cs02 CSS Selectors cs03 CSS Inclusion cs04 CSS Measurement Units cs05 CSS Paddings Property REF http
Values and units, in CSS, are significant as they determine the size, proportions, and positioning of elements on a web
A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in you