怎样使用plgblt的hbmMask参数?

RainStoneMail 2003-05-09 02:45:35
如题
...全文
56 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
RainStoneMail 2003-05-09
  • 打赏
  • 举报
回复
风尘兄,能够给一个单色掩模的例子,谢谢
道素 2003-05-09
  • 打赏
  • 举报
回复
hbmMask
Long,
一个可选的句柄,指向一个单色掩模。如设定了这个参数,那么只有与掩模值1对应的二进制位才会传输到目的地

SHANNON
----------------
CH21ST@HOTMAIL.COM
道素 2003-05-09
  • 打赏
  • 举报
回复
hbmMask
Identifies an optional monochrome bitmap that is used to mask the colors of the source rectangle.

例子:
Const BI_RGB = 0
Const DIB_RGB_COLORS = 0 ' color table in RGBs
Const DIB_PAL_COLORS = 1 ' color table in palette indices
Const PATCOPY = &HF00021 ' (DWORD) dest = pattern
Const PATINVERT = &H5A0049 ' (DWORD) dest = pattern XOR dest
Const PATPAINT = &HFB0A09 ' (DWORD) dest = DPSnoo
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
End Type
Private Type tBITMAP
Header As BITMAPINFO
Bytes(0 To 63) As Byte
End Type
Private Declare Function CreateDIBPatternBrushPt Lib "gdi32" (lpPackedDIB As Any, ByVal iUsage As Long) As Long
Private Declare Function PlgBlt Lib "gdi32" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long
Private Declare Function PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Paint()

Dim hBrush As Long, tBr As tBITMAP, Cnt As Long, hOld As Long
Dim Pt(0 To 2) As POINTAPI
'set the co鰎dinates of the parallelogram
Pt(0).x = 30
Pt(0).y = 10
Pt(1).x = 300
Pt(1).y = 0
Pt(2).x = 0
Pt(2).y = 300
'resize and modify a screenshot
PlgBlt Me.hdc, Pt(0), GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, ByVal 0&, ByVal 0&, ByVal 0&
'initialize the tBITMAP-structure
With tBr.Header.bmiHeader
.biSize = Len(tBr.Header.bmiHeader)
.biCompression = BI_RGB
.biHeight = 8
.biPlanes = 1
.biWidth = 8
.biBitCount = 1
End With
For Cnt = 0 To 7
tBr.Bytes(Cnt) = 128
Next Cnt
'create a pattern brush
hBrush = CreateDIBPatternBrushPt(tBr, DIB_RGB_COLORS)
'select the brush into the form's DC
hOld = SelectObject(Me.hdc, hBrush)
'Perform the Pattern Block Transfer
PatBlt Me.hdc, 0, 0, 30, 30, PATCOPY
'restore the old brush and delete our pattern brush
DeleteObject SelectObject(Me.hdc, hOld)
End Sub


SHANNON
----------------
CH21ST@HOTMAIL.COM

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧