@@ -731,6 +731,23 @@ const (
731
731
GRADIENT_FILL_TRIANGLE = 0x02
732
732
)
733
733
734
+ // Region Combine Modes
735
+ const (
736
+ RGN_AND = 1
737
+ RGN_OR = 2
738
+ RGN_XOR = 3
739
+ RGN_DIFF = 4
740
+ RGN_COPY = 5
741
+ )
742
+
743
+ // Region Types
744
+ const (
745
+ REGIONERROR = 0
746
+ NULLREGION = 1
747
+ SIMPLEREGION = 2
748
+ COMPLEXREGION = 3
749
+ )
750
+
734
751
type (
735
752
COLORREF uint32
736
753
HBITMAP HGDIOBJ
@@ -741,7 +758,7 @@ type (
741
758
HENHMETAFILE HANDLE
742
759
HPALETTE HGDIOBJ
743
760
HPEN HGDIOBJ
744
- HREGION HGDIOBJ
761
+ HRGN HGDIOBJ
745
762
)
746
763
747
764
type PIXELFORMATDESCRIPTOR struct {
@@ -1001,6 +1018,7 @@ var (
1001
1018
bitBlt uintptr
1002
1019
choosePixelFormat uintptr
1003
1020
closeEnhMetaFile uintptr
1021
+ combineRgn uintptr
1004
1022
copyEnhMetaFile uintptr
1005
1023
createBitmap uintptr
1006
1024
createCompatibleBitmap uintptr
@@ -1012,6 +1030,7 @@ var (
1012
1030
createEnhMetaFile uintptr
1013
1031
createIC uintptr
1014
1032
createPatternBrush uintptr
1033
+ createRectRgn uintptr
1015
1034
deleteDC uintptr
1016
1035
deleteEnhMetaFile uintptr
1017
1036
deleteObject uintptr
@@ -1020,12 +1039,14 @@ var (
1020
1039
endPage uintptr
1021
1040
excludeClipRect uintptr
1022
1041
extCreatePen uintptr
1042
+ fillRgn uintptr
1023
1043
getDeviceCaps uintptr
1024
1044
getDIBits uintptr
1025
1045
getEnhMetaFile uintptr
1026
1046
getEnhMetaFileHeader uintptr
1027
1047
getObject uintptr
1028
1048
getPixel uintptr
1049
+ getRgnBox uintptr
1029
1050
getStockObject uintptr
1030
1051
getTextExtentExPoint uintptr
1031
1052
getTextExtentPoint32 uintptr
@@ -1055,6 +1076,7 @@ var (
1055
1076
stretchBlt uintptr
1056
1077
swapBuffers uintptr
1057
1078
textOut uintptr
1079
+ transparentBlt uintptr
1058
1080
)
1059
1081
1060
1082
func init () {
@@ -1067,6 +1089,7 @@ func init() {
1067
1089
bitBlt = MustGetProcAddress (libgdi32 , "BitBlt" )
1068
1090
choosePixelFormat = MustGetProcAddress (libgdi32 , "ChoosePixelFormat" )
1069
1091
closeEnhMetaFile = MustGetProcAddress (libgdi32 , "CloseEnhMetaFile" )
1092
+ combineRgn = MustGetProcAddress (libgdi32 , "CombineRgn" )
1070
1093
copyEnhMetaFile = MustGetProcAddress (libgdi32 , "CopyEnhMetaFileW" )
1071
1094
createBitmap = MustGetProcAddress (libgdi32 , "CreateBitmap" )
1072
1095
createCompatibleBitmap = MustGetProcAddress (libgdi32 , "CreateCompatibleBitmap" )
@@ -1078,6 +1101,7 @@ func init() {
1078
1101
createFontIndirect = MustGetProcAddress (libgdi32 , "CreateFontIndirectW" )
1079
1102
createIC = MustGetProcAddress (libgdi32 , "CreateICW" )
1080
1103
createPatternBrush = MustGetProcAddress (libgdi32 , "CreatePatternBrush" )
1104
+ createRectRgn = MustGetProcAddress (libgdi32 , "CreateRectRgn" )
1081
1105
deleteDC = MustGetProcAddress (libgdi32 , "DeleteDC" )
1082
1106
deleteEnhMetaFile = MustGetProcAddress (libgdi32 , "DeleteEnhMetaFile" )
1083
1107
deleteObject = MustGetProcAddress (libgdi32 , "DeleteObject" )
@@ -1086,12 +1110,14 @@ func init() {
1086
1110
endPage = MustGetProcAddress (libgdi32 , "EndPage" )
1087
1111
excludeClipRect = MustGetProcAddress (libgdi32 , "ExcludeClipRect" )
1088
1112
extCreatePen = MustGetProcAddress (libgdi32 , "ExtCreatePen" )
1113
+ fillRgn = MustGetProcAddress (libgdi32 , "FillRgn" )
1089
1114
getDeviceCaps = MustGetProcAddress (libgdi32 , "GetDeviceCaps" )
1090
1115
getDIBits = MustGetProcAddress (libgdi32 , "GetDIBits" )
1091
1116
getEnhMetaFile = MustGetProcAddress (libgdi32 , "GetEnhMetaFileW" )
1092
1117
getEnhMetaFileHeader = MustGetProcAddress (libgdi32 , "GetEnhMetaFileHeader" )
1093
1118
getObject = MustGetProcAddress (libgdi32 , "GetObjectW" )
1094
1119
getPixel = MustGetProcAddress (libgdi32 , "GetPixel" )
1120
+ getRgnBox = MustGetProcAddress (libgdi32 , "GetRgnBox" )
1095
1121
getStockObject = MustGetProcAddress (libgdi32 , "GetStockObject" )
1096
1122
getTextExtentExPoint = MustGetProcAddress (libgdi32 , "GetTextExtentExPointW" )
1097
1123
getTextExtentPoint32 = MustGetProcAddress (libgdi32 , "GetTextExtentPoint32W" )
@@ -1122,6 +1148,7 @@ func init() {
1122
1148
textOut = MustGetProcAddress (libgdi32 , "TextOutW" )
1123
1149
1124
1150
gradientFill = MustGetProcAddress (libmsimg32 , "GradientFill" )
1151
+ transparentBlt = MustGetProcAddress (libmsimg32 , "TransparentBlt" )
1125
1152
}
1126
1153
1127
1154
func AbortDoc (hdc HDC ) int32 {
@@ -1166,6 +1193,18 @@ func CloseEnhMetaFile(hdc HDC) HENHMETAFILE {
1166
1193
return HENHMETAFILE (ret )
1167
1194
}
1168
1195
1196
+ func CombineRgn (hrgnDest , hrgnSrc1 , hrgnSrc2 HRGN , fnCombineMode int32 ) int32 {
1197
+ ret , _ , _ := syscall .Syscall6 (combineRgn , 4 ,
1198
+ uintptr (hrgnDest ),
1199
+ uintptr (hrgnSrc1 ),
1200
+ uintptr (hrgnSrc2 ),
1201
+ uintptr (fnCombineMode ),
1202
+ 0 ,
1203
+ 0 )
1204
+
1205
+ return int32 (ret )
1206
+ }
1207
+
1169
1208
func CopyEnhMetaFile (hemfSrc HENHMETAFILE , lpszFile * uint16 ) HENHMETAFILE {
1170
1209
ret , _ , _ := syscall .Syscall (copyEnhMetaFile , 2 ,
1171
1210
uintptr (hemfSrc ),
@@ -1280,6 +1319,18 @@ func CreatePatternBrush(hbmp HBITMAP) HBRUSH {
1280
1319
return HBRUSH (ret )
1281
1320
}
1282
1321
1322
+ func CreateRectRgn (nLeftRect , nTopRect , nRightRect , nBottomRect int32 ) HRGN {
1323
+ ret , _ , _ := syscall .Syscall6 (createRectRgn , 4 ,
1324
+ uintptr (nLeftRect ),
1325
+ uintptr (nTopRect ),
1326
+ uintptr (nRightRect ),
1327
+ uintptr (nBottomRect ),
1328
+ 0 ,
1329
+ 0 )
1330
+
1331
+ return HRGN (ret )
1332
+ }
1333
+
1283
1334
func DeleteDC (hdc HDC ) bool {
1284
1335
ret , _ , _ := syscall .Syscall (deleteDC , 1 ,
1285
1336
uintptr (hdc ),
@@ -1361,6 +1412,15 @@ func ExtCreatePen(dwPenStyle, dwWidth uint32, lplb *LOGBRUSH, dwStyleCount uint3
1361
1412
return HPEN (ret )
1362
1413
}
1363
1414
1415
+ func FillRgn (hdc HDC , hrgn HRGN , hbr HBRUSH ) bool {
1416
+ ret , _ , _ := syscall .Syscall (fillRgn , 3 ,
1417
+ uintptr (hdc ),
1418
+ uintptr (hrgn ),
1419
+ uintptr (hbr ))
1420
+
1421
+ return ret != 0
1422
+ }
1423
+
1364
1424
func GetDeviceCaps (hdc HDC , nIndex int32 ) int32 {
1365
1425
ret , _ , _ := syscall .Syscall (getDeviceCaps , 2 ,
1366
1426
uintptr (hdc ),
@@ -1420,6 +1480,15 @@ func GetPixel(hdc HDC, nXPos, nYPos int32) COLORREF {
1420
1480
return COLORREF (ret )
1421
1481
}
1422
1482
1483
+ func GetRgnBox (hrgn HRGN , lprc * RECT ) int32 {
1484
+ ret , _ , _ := syscall .Syscall (getRgnBox , 2 ,
1485
+ uintptr (hrgn ),
1486
+ uintptr (unsafe .Pointer (lprc )),
1487
+ 0 )
1488
+
1489
+ return int32 (ret )
1490
+ }
1491
+
1423
1492
func GetStockObject (fnObject int32 ) HGDIOBJ {
1424
1493
ret , _ , _ := syscall .Syscall (getStockObject , 1 ,
1425
1494
uintptr (fnObject ),
@@ -1719,3 +1788,21 @@ func TextOut(hdc HDC, nXStart, nYStart int32, lpString *uint16, cchString int32)
1719
1788
0 )
1720
1789
return ret != 0
1721
1790
}
1791
+
1792
+ func TransparentBlt (hdcDest HDC , xoriginDest , yoriginDest , wDest , hDest int32 , hdcSrc HDC , xoriginSrc , yoriginSrc , wSrc , hSrc int32 , crTransparent uint32 ) bool {
1793
+ ret , _ , _ := syscall .Syscall12 (transparentBlt , 11 ,
1794
+ uintptr (hdcDest ),
1795
+ uintptr (xoriginDest ),
1796
+ uintptr (yoriginDest ),
1797
+ uintptr (wDest ),
1798
+ uintptr (hDest ),
1799
+ uintptr (hdcSrc ),
1800
+ uintptr (xoriginSrc ),
1801
+ uintptr (yoriginSrc ),
1802
+ uintptr (wSrc ),
1803
+ uintptr (hSrc ),
1804
+ uintptr (crTransparent ),
1805
+ 0 )
1806
+
1807
+ return ret != 0
1808
+ }
0 commit comments