找回密码
 加入
搜索
查看: 3819|回复: 1

[图形处理] 在GUI上面显示透明的位图例子:数组有没有快捷的转换UDF!

[复制链接]
发表于 2015-7-21 16:54:22 | 显示全部楼层 |阅读模式
本帖最后由 ioripalm 于 2015-7-22 11:21 编辑

看到一个比较好的位图显示透明的例子!
试着修改了一下里面的数组,可以在GUI上面得到一个透明的镂空图案。
这个数组是我一个字一个字敲的,请问谁知道如何根据一个BMP位图来自动生成这样的数组,有没有这样的UDF。
代码如下:
#include <GUIConstants.au3>
#include <Array.au3>

Global $SQLResultWindow 
$SQLResultWindow = GUICreate("位图透明效果", 270, 50, -1, -1, -1, $WS_EX_ACCEPTFILES)
Local $_Left_pos, $_Top_pos, $_GUI_NAME
$_Left_pos = 10 ; Replace with correct position
$_Top_pos = 40 ; Replace with correct position
$_GUI_NAME = $SQLResultWindow
_GuiImageHole($_GUI_NAME, $_Left_pos, $_Top_pos, 220, 32)

GUISetState()
        While 1
                $mainmsg = GUIGetMsg()
                        Select
                Case $mainmsg = $GUI_EVENT_CLOSE 
                        Exit
                EndSelect
WEnd
                


Func _GuiImageHole($window_handle, $pos_x, $pos_y,$Image_Width ,$Image_Height)
    Local $aClassList, $aM_Mask, $aMask
#Region picture array
Local $PictArray[63]
$PictArray[0] = '1,1,8,1'
$PictArray[1] = '50,1,70,1'
$PictArray[2] = '1,2,8,2'
$PictArray[3] = '50,2,70,2'
$PictArray[4] = '1,3,8,3'
$PictArray[5] = '50,3,70,3'
$PictArray[6] = '1,4,8,4'
$PictArray[7] = '50,4,70,4'
$PictArray[8] = '1,5,8,5'
$PictArray[9] = '50,5,70,5'
$PictArray[10] = '1,6,8,6'
$PictArray[11] = '50,6,70,6'
$PictArray[12] = '1,7,8,7'
$PictArray[13] = '50,7,70,7'
$PictArray[14] = '1,8,8,8'
$PictArray[15] = '20,8,70,8'
$PictArray[16] = '1,9,8,9'
$PictArray[17] = '20,9,70,9'
$PictArray[18] = '1,10,8,10'
$PictArray[19] = '20,10,70,10'
$PictArray[20] = '1,11,8,11'
$PictArray[21] = '20,11,70,11'
$PictArray[22] = '1,12,8,12'
$PictArray[23] = '20,12,70,12'
$PictArray[24] = '1,13,8,13'
$PictArray[25] = '50,13,70,13'
$PictArray[26] = '1,14,8,14'
$PictArray[27] = '50,14,70,14'
$PictArray[28] = '1,15,8,15'
$PictArray[29] = '50,15,70,15'
$PictArray[30] = '1,16,8,16'
$PictArray[31] = '50,16,70,16'
$PictArray[32] = '1,17,8,17'
$PictArray[33] = '50,17,70,17'
$PictArray[34] = '1,18,8,18'
$PictArray[35] = '50,18,70,18'
$PictArray[36] = '1,19,8,19'
$PictArray[37] = '50,19,70,19'
$PictArray[38] = '1,20,8,20'
$PictArray[39] = '20,20,70,20'
$PictArray[40] = '1,21,8,21'
$PictArray[41] = '20,21,70,21'
$PictArray[42] = '1,22,8,22'
$PictArray[43] = '20,22,70,22'
$PictArray[44] = '1,23,8,23'
$PictArray[45] = '20,23,70,23'
$PictArray[46] = '1,24,8,24'
$PictArray[47] = '20,24,70,24'
$PictArray[48] = '1,25,8,25'
$PictArray[49] = '50,25,70,25'
$PictArray[50] = '1,26,8,26'
$PictArray[51] = '50,26,70,26'
$PictArray[52] = '1,27,8,27'
$PictArray[53] = '50,27,70,27'
$PictArray[54] = '1,28,8,28'
$PictArray[55] = '50,28,70,28'
$PictArray[56] = '1,29,8,29'
$PictArray[57] = '50,29,70,29'
$PictArray[58] = '1,30,8,30'
$PictArray[59] = '50,30,70,30'
$PictArray[60] = '1,31,8,31'
$PictArray[61] = '50,31,70,31'
$PictArray[62] = '1,32,220,32'
#Region picture array

        ; get the size of the active window
        $size = WinGetClientSize($window_handle)
        $Window_width = $size[0]
        $Window_height = $size[1] + 40 ; include height of title bar up to 30 dots
        ; First hide the window
        $aClassList = StringSplit(_WinGetClassListEx($window_handle), @LF)
        $aM_Mask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', 0, 'long', 0)
        ; rectangle A - left side
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', $pos_x, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask[0], 'long', $aMask[0], 'long', $aM_Mask[0], 'int', 2)
        ; rectangle B - Top
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0, 'long', 0, 'long', $Window_width, 'long', $pos_y)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask[0], 'long', $aMask[0], 'long', $aM_Mask[0], 'int', 2)
        ; rectangle C - Right side
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', $pos_x  + $Image_Width , 'long', 0 , 'long', $Window_width + 30, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask[0], 'long', $aMask[0], 'long', $aM_Mask[0], 'int', 2)
        ; rectangle D - Bottom
        $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', 0 , 'long', $pos_y + $Image_Height, 'long', $Window_width, 'long', $Window_height)
        DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask[0], 'long', $aMask[0], 'long', $aM_Mask[0], 'int', 2)
        ; now unhide all regions as defined  in array $PictArray
        For $i = 0 To (UBound($PictArray) - 1)
                $Block_value = StringSplit($PictArray[$i],',')
                $aMask = DllCall('gdi32.dll', 'long', 'CreateRectRgn', 'long', $pos_x + $Block_value[1] - 1 , 'long', $pos_y + $Block_value[2], 'long', $pos_x + $Block_value[3], 'long', $pos_y + $Block_value[4] -1)
                DllCall('gdi32.dll', 'long', 'CombineRgn', 'long', $aM_Mask[0], 'long', $aMask[0], 'long', $aM_Mask[0], 'int', 2)
        Next
        DllCall('user32.dll', 'long', 'SetWindowRgn', 'hwnd', $window_handle, 'long', $aM_Mask[0], 'int', 1)
        $PictArray='' ; empty array
EndFunc  ;==>_GuiImageHole
Func _WinGetClassListEx($sTitle)
    Local $sClassList = WinGetClassList($sTitle)
    Local $aClassList = StringSplit($sClassList, @LF)
    Local $sRetClassList = '', $sHold_List = '|'
    Local $aiInHold, $iInHold
    For $i = 1 To UBound($aClassList) - 1
        If $aClassList[$i] = '' Then ContinueLoop
        If StringRegExp($sHold_List, '\|' & $aClassList[$i] & '~(\d+)\|') Then
            $aiInHold = StringRegExp($sHold_List, '.*\|' & $aClassList[$i] & '~(\d+)\|.*', 1)
            $iInHold = Number($aiInHold[UBound($aiInHold)-1])
            If $iInHold = 0 Then $iInHold += 1
            $aClassList[$i] &= '~' & $iInHold + 1
            $sHold_List &= $aClassList[$i] & '|'
            $sRetClassList &= $aClassList[$i] & @LF
        Else
            $aClassList[$i] &= '~1'
            $sHold_List &= $aClassList[$i] & '|'
            $sRetClassList &= $aClassList[$i] & @LF
        EndIf
    Next
    Return StringReplace(StringStripWS($sRetClassList, 3), '~', '')
EndFunc ;==>_WinGetClassListEx
效果如下:


论坛有人发过这样的代码!
请问数组都要自己一个字一个字的敲吗?
http://www.autoitx.com/forum.php?mod=viewthread&tid=4644&highlight=%EF%CE%BF%D5
http://www.autoitx.com/forum.php?mod=viewthread&tid=20916&highlight=%EF%CE%BF%D5
 楼主| 发表于 2015-7-22 11:06:52 | 显示全部楼层
有没有人知道的呀!帮忙找一下好不!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 02:56 , Processed in 0.085624 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表