Leaderboard
Popular Content
Showing content with the highest reputation on 03/28/2024 in all areas
-
In my experience on this forum, both in the "old days" and now, I've found the people warm and welcoming and very helpful. As a guy who was generally the smartest guy in the room at almost every job I've held, I'm humbled by how much smarter the regulars are here. If @Nine @argumentum @Melba23 and some of the others comment on your thread, they are top talent, not just rando forum trolls on power trips. With that in mind, you do get what you put in: if you're willing to put in the effort, you'll get effort in return. If you're bitter/angry/combative/a dick because of your frustration, you'll get shut down. Frustration happens when you're banging you head against a thing that appears to make no sense, but please strip that out when you post your code That aside, AutoIt syntax is similar to VB (and because of that I've been able to learn a tiny bit of VB along the way but that's beside the point). The brackets are nested and denote optional arguments: for every "[" you have to have a matching, ending "]" to close it. Each argument is bracketed because they are independent. A single set of brackets would mean they all need to be included. The samples in the help really are a lifesaver. Run them, make changes, re-run them; learn and see how it works. When I started getting ahold on the fundamentals it was an exciting light bulb moment for me. I hope you'll have the same. As I said above, these are a great bunch of smart people and are very willing to help if you're showing the effort and leaving the most negative feelings on your side of the keyboard.3 points
-
Is it really nearly 4 years since I had to do this? Such a pity that I now have to post anew in this section. Our friend in the title of this thread has been remittingly negative about AutoIt since his arrival here - and has the most unfortunate tendency to refer to AHK almost every time he opens a thread. But worse, he has resorted to ad hominen attacks against MVPs and, rather foolishly, the Mod team. He is now taking a short holiday to consider whether his attitude should change, as it must if he wishes to remain part of this community, or whether he would be better off elsewhere. M232 points
-
collection of round buttons ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RoundButtons.au3 ; Description.....: collection of round buttons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $MyGui, $aBtn[7][2] Example() Func Example() $MyGui = GUICreate(" My GUI Icons", 300, 500) $aBtn[0][0] = 6 ; cnt of buttons $aBtn[1][1] = "red" $aBtn[1][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[1][1] & "_normal.ico", 0, 20, 20, 64, 64, $SS_NOTIFY) $aBtn[2][1] = "yellow" $aBtn[2][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[2][1] & "_normal.ico", 0, 20, 100, 64, 64, $SS_NOTIFY) $aBtn[3][1] = "green" $aBtn[3][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[3][1] & "_normal.ico", 0, 20, 180, 64, 64, $SS_NOTIFY) $aBtn[4][1] = "turquoise" $aBtn[4][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[4][1] & "_normal.ico", 0, 20, 260, 64, 64, $SS_NOTIFY) $aBtn[5][1] = "cyan" $aBtn[5][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[5][1] & "_normal.ico", 0, 20, 340, 64, 64, $SS_NOTIFY) $aBtn[6][1] = "magenta" $aBtn[6][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[6][1] & "_normal.ico", 0, 20, 420, 64, 64, $SS_NOTIFY) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $aBtn[1][0] ConsoleWrite($aBtn[1][1] & @CRLF) Case $aBtn[2][0] ConsoleWrite($aBtn[2][1] & @CRLF) Case $aBtn[3][0] ConsoleWrite($aBtn[3][1] & @CRLF) Case $aBtn[4][0] ConsoleWrite($aBtn[4][1] & @CRLF) Case $aBtn[5][0] ConsoleWrite($aBtn[5][1] & @CRLF) Case $aBtn[6][0] ConsoleWrite($aBtn[6][1] & @CRLF) EndSwitch _IsOver() WEnd GUIDelete() EndFunc ;==>Example Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_normal.ico") EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_click.ico") $iClicked = 1 Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") $iClicked = 0 EndIf EndIf Next EndIf EndFunc ;==>_IsOver Extract buttons folder in @ScriptDir Buttons.zip Please, every comment is appreciated! leave your comments and experiences here! Thank you very much1 point
-
First of all, it is of course your decision as a moderator to issue a formal warning and a time ban. However, I personally highly doubt that any of these measures will change the behavior of this arrogant jackass. I would even consider the aggressive attacks to be an argumentum ad personam, not just an argumentum ad hominem (which would be bad enough already). With his insults against @Nine , @kirb has crossed every line that I consider acceptable (newbie or not). Some people don't deserve a second chance and should be removed from the system immediately. (just my 2 cents)1 point
-
Moved to the appropriate AutoIt General Help and Support forum, as the AutoIt Example Scripts forum very clearly states: Moderation Team1 point
-
look at your help for _WinAPI_GetDriveBusType1 point
-
kirb, That type of syntax has been in use for at least the past 35 years to indicate optional parameters and default values - even my old DOS programs written in Assembler used it! And there are separate brackets because in AutoIt you must supply a value for optional parameters (even if that is the default value) when you are going to use non-default parameters later in the call. All this is clearly explained in the Help file: https://www.autoitscript.com/autoit3/docs/function_notes.htm Now, regarding your ad hominen attack on one of our forum's MVPs, I find it well out of line for a complete newbie to post such a diatribe. Please adjust your attitude or your stay here will not be long. Consider this a formal warning. M231 point
-
Round buttons
argumentum reacted to ioa747 for a topic
the icon's $SS_NOTIFY style is responsible for this. I don't know how this can change Edit: I found another way Special Edition: ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RoundButtonsSpecial.au3 ; Description.....: collection of round buttons - Special Edition ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $MyGui, $aBtn[7][2] Example() ;---------------------------------------------------------------------------------------- Func Example() $MyGui = GUICreate(" My GUI Icons", 300, 500) $aBtn[0][0] = 6 ; cnt of buttons $aBtn[1][1] = "red" $aBtn[1][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[1][1] & "_normal.ico", 0, 20, 20, 64, 64) $aBtn[2][1] = "yellow" $aBtn[2][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[2][1] & "_normal.ico", 0, 20, 100, 64, 64) $aBtn[3][1] = "green" $aBtn[3][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[3][1] & "_normal.ico", 0, 20, 180, 64, 64) $aBtn[4][1] = "turquoise" $aBtn[4][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[4][1] & "_normal.ico", 0, 20, 260, 64, 64) $aBtn[5][1] = "cyan" $aBtn[5][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[5][1] & "_normal.ico", 0, 20, 340, 64, 64) $aBtn[6][1] = "magenta" $aBtn[6][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[6][1] & "_normal.ico", 0, 20, 420, 64, 64) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _IsOver() WEnd GUIDelete() EndFunc ;==>Example ;---------------------------------------------------------------------------------------- Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_normal.ico") EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_click.ico") $iClicked = 1 Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") $iClicked = 0 _ButtonCaller($aBtn[$i][0]) EndIf EndIf Next EndIf EndFunc ;==>_IsOver ;---------------------------------------------------------------------------------------- Func _ButtonCaller($Btn) Switch $Btn Case $aBtn[1][0] ConsoleWrite($aBtn[1][1] & @CRLF) Case $aBtn[2][0] ;"yellow" ConsoleWrite($aBtn[2][1] & @CRLF) Case $aBtn[3][0] ;"green" ConsoleWrite($aBtn[3][1] & @CRLF) Case $aBtn[4][0] ;"turquoise" ConsoleWrite($aBtn[4][1] & @CRLF) Case $aBtn[5][0] ;"cyan" ConsoleWrite($aBtn[5][1] & @CRLF) Case $aBtn[6][0] ;"magenta" ConsoleWrite($aBtn[6][1] & @CRLF) EndSwitch EndFunc ;----------------------------------------------------------------------------------------1 point -
Round buttons
ioa747 reacted to argumentum for a topic
Very nice. Do place the example in the zip for those that are lazy ( not me ) And a request would be that the action is on button release ( up ) instead of down Again, quite nice. Thanks for sharing.1 point -
BMP3.3 produces errors in BMP3.au3 here is a small fix: #include-once ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.3.6.1 ; Author: Evilertoaster <evilertoaster at yahoo dot com> ; ; Script Function: ; Basic BMP file managment. ;Script Version: ; 3.3 ; ---------------------------------------------------------------------------- ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMPCreate ; Description ...: Creates a BMP 'Handle' to be used in later functions. The BMP dimensions will be decided by the parameters. ; Syntax.........: _BMPCreate($Width,$Height) ; Parameters ....: $Width - "" in pixels ; $Height - "" in pixels ; Return values .: Success - A BMP handle ; #FUNCTION# ==================================================================================================================== Func _BMPCreate ($Width,$Height) Local $c=Mod($Width,4) Local $d=Binary("") if $c=3 then $d=Binary("0x000000") if $c=2 then $d=Binary("0x0000") if $c=1 then $d=Binary("0x00") ;***BMP header (54bytes total)*** Local $Header=Binary("0x424D"& _ ;2bytes, BM signature "00000000"& _ ;4bytes, filesize (optional, omitted) "0000"& _ ;2bytes, reserved "0000"& _ ;2bytes, reserved "36000000"& _ ;4bytes, offset to image data "28000000"& _ ;4bytes, BITMAPINFOHEADER _Reverse8(Hex($Width,8))& _ ;4bytes, bitmap width _Reverse8(Hex($Height,8))& _ ;4bytes, bitmap hieght "0100"& _ ;2bytes, bitmap planes "1800"& _ ;2bytes, bitmap bitdepth "00000000"& _ ;4bytes, bitmap compression type (none) _Reverse8(Hex(($Height)* _ ($Width)*3+($Height*$c),8))& _ ;4bytes, bitmap data size "00000000"& _ ;4bytes, bitmap horizontal resolution (optional,omitted) "00000000"& _ ;4bytes, bitmap vertical resolution (optional,omitted) "00000000"& _ ;4bytes, bitmap colors (optional?, omitted) "00000000") ;4bytes, important colors (optional?, omitted) ;***End Header*** Local $rowData=Binary("") Local $imageData=Binary("") for $n=1 to $Width $rowData&=Binary("0xFFFFFF") Next $rowData&=$d for $m=1 to $Height $imageData&=$rowData Next Local $binaryData=$Header&$imageData Local $BMPHandle[4] $BMPHandle[0]=$c $BMPHandle[1]=$Width $BMPHandle[2]=$Height $BMPHandle[3]=DllStructCreate('ubyte['&BinaryLen($binaryData)&']') DllStructSetData($BMPHandle[3],1,$binaryData) Return $BMPHandle EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMPOpen ; Description ...: Creates a BMP 'Handle' from a BMP file. ; Syntax.........: _BMPOpen($Path) ; Parameters ....: $Path - Path to the file ; Return values .: Success - A BMP handle ; Failure - -1: FileOpen() returned -1 ; -2: Not a valid BMP file header ; -3: BMP file header has invalid hieght or width specified ; #FUNCTION# ==================================================================================================================== Func _BMPOpen($Path,$Progress=1) Local $Bpath=FileOpen($Path,16) If $Bpath=-1 then Return -1 $AllOf=FileRead($Bpath) FileClose($Bpath) If BinaryMid($AllOf,1,2)<>"0x424D" then Return -2 $x=Dec(_Reverse8(Hex(BinaryMid($AllOf,19,4)))) $y=Dec(_Reverse8(Hex(BinaryMid($AllOf,23,4)))) if $x=0 or $y=0 then Return -3 for $c=$x to 0 step -4 if $c<4 then ExitLoop Next Local $BMPHandle[4] $BMPHandle[0]=$c $BMPHandle[1]=$x $BMPHandle[2]=$y $BMPHandle[3]=DllStructCreate('ubyte['&BinaryLen($AllOf)&']') DllStructSetData($BMPHandle[3],1,$AllOf) return $BMPHandle EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _PixelRead ; Description ...: Returns the color at the pixel coordinate and BMPHandle given. ; Syntax.........: _PixelRead($BMPHandle,$X,$Y) ; Parameters ....: $BMPHandle - "" ; $X - X coordinate of the pixel ; $Y - "" ; Return values .: Success - A Color as a hex string in RRGGBB format ; #FUNCTION# ==================================================================================================================== Func _PixelRead(ByRef $BMPHandle,$x,$y) If IsArray($BMPHandle)=False or $x>$BMPHandle[1]-1 Or $x<0 Or $y>$BMPHandle[2]-1 Or $y<0 Then Return 0 local $offset = _ChordToOffset($BMPHandle, $x, $y) Return hex(DllStructGetData($BMPHandle[3],1,$offset+3),2)&hex(DllStructGetData($BMPHandle[3],1,$offset+2),2)&hex(DllStructGetData($BMPHandle[3],1,$offset+1),2) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _PixelWrite ; Description ...: Writes the color to the pixel coordinate and BMPHandle given. ; Syntax.........: _PixelWrite($BMPHandle,$X,$Y,$Color) ; Parameters ....: $BMPHandle - "" ; $X - X coordinate of the pixel ; $Y - "" ; $Color - A Color as a hex string in RRGGBB format (e.g. "AAFF00") ; Return values .: Success - Returns 1 ; #FUNCTION# ==================================================================================================================== Func _PixelWrite(ByRef $BMPHandle,$x,$y,$color) If $x>$BMPHandle[1]-1 Or $x<0 Or $y>$BMPHandle[2]-1 Or $y<0 or StringLen($color)<>6 Then Return 0 local $offset = _ChordToOffset($BMPHandle, $x, $y) DllStructSetData($BMPHandle[3],1,dec(StringLeft($color,2)),$offset+3) DllStructSetData($BMPHandle[3],1,dec(stringmid($color,3,2)),$offset+2) DllStructSetData($BMPHandle[3],1,dec(StringRight($color,2)),$offset+1) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMPWrite ; Description ...: Writes the BMP Handle $BMPHandle to the file path $Fpath. ; Syntax.........: _BMPWrite($BMPHandle,$Fpath) ; Parameters ....: $BMPHandle - "" ; $Fpath - Path to the file; ; Return values .: Success - Returns 1 ; Failure - -1: FileOpen() returned -1 ; #FUNCTION# ==================================================================================================================== Func _BMPWrite(ByRef $BMPHandle,$Fpath) if IsArray($BMPHandle)=False then Return 0 $out=FileOpen($Fpath,18) if $out=-1 then return -1 FileWrite($out,DllStructGetData($BMPHandle[3],1)) FileClose($out) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMPGetWidth ; Description ...: Returns the width in pixels of the BMP. Same as $BMPHandle[1]. ; Syntax.........: _BMPGetWidth($BMPHandle) ; Parameters ....: $BMPHandle - "" ; #FUNCTION# ==================================================================================================================== Func _BMPGetWidth(ByRef $BMPHandle) If IsArray($BMPHandle)=0 Then Return 0 Return $BMPHandle[1] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMPGetHeight ; Description ...: Returns the Height in pixels of the BMP. Same as $BMPHandle[2]. ; Syntax.........: _BMPGetHeight($BMPHandle) ; Parameters ....: $BMPHandle - "" ; #FUNCTION# ==================================================================================================================== Func _BMPGetHeight(ByRef $BMPHandle) If IsArray($BMPHandle)=0 Then Return 0 Return $BMPHandle[2] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _PixelFill ; Description ...: Does a paint "fill" effect on the given pixel with the given color. It will also shade in pixels within the ; given shade variation (defualt 0 is exact match for pixel color, 1 would allow 1 shade lighter or darker than ; the starting pixel ect.). ; Syntax.........: _PixelFill($BMPHandle,$x,$y,$color[,$variation=0]) ; Parameters ....: $BMPHandle,$x,$y,$color see _PixelWrite() ; Return values .: Success - Returns the number of pixels filled ; #FUNCTION# ==================================================================================================================== Func _PixelFill(ByRef $BMPHandle,$x,$y,$color,$variation=0) Local $CheckChart[UBound($BMPHandle,1)][UBound($BMPHandle,2)] Local $count=0 $Tset=1 Local $tracer[$Tset] $tracer[$tset-1]=$x&","&$y Local $CheckColor=Dec(_PixelRead($BMPHandle,$x,$y)) $CheckChart[$y][$x]=1 While 1 if Abs(Dec(_PixelRead($BMPHandle,$x-1,$y))-$CheckColor)<=$variation Then $CheckChart[$x-1][$y]=1 $count+=1 _PixelWrite($BMPHandle,$x-1,$y,$color) $Tset+=1 ReDim $tracer[$Tset] $tracer[$Tset-1]=$x&","&$y $x=$x-1 ContinueLoop EndIf if Abs(Dec(_PixelRead($BMPHandle,$x,$y-1))-$CheckColor)<=$variation Then $CheckChart[$x][$y-1]=1 $count+=1 _PixelWrite($BMPHandle,$x,$y-1,$color) $Tset+=1 ReDim $tracer[$Tset] $tracer[$Tset-1]=$x&","&$y $y=$y-1 ContinueLoop EndIf if Abs(Dec(_PixelRead($BMPHandle,$x+1,$y))-$CheckColor)<=$variation Then $CheckChart[$x+1][$y]=1 $count+=1 _PixelWrite($BMPHandle,$x+1,$y,$color) $Tset+=1 ReDim $tracer[$Tset] $tracer[$Tset-1]=$x&","&$y $x=$x+1 ContinueLoop EndIf if Abs(Dec(_PixelRead($BMPHandle,$x,$y+1))-$CheckColor)<=$variation Then $CheckChart[$x][$y+1]=1 $count+=1 _PixelWrite($BMPHandle,$x,$y+1,$color) $Tset+=1 ReDim $tracer[$Tset] $tracer[$Tset-1]=$x&","&$y $y=$y+1 ContinueLoop EndIf $Point=StringSplit($tracer[$Tset-1],",") $x=$Point[1] $y=$Point[2] $Tset-=1 ReDim $tracer[$Tset] if $tset=1 then ExitLoop Wend Return $count EndFunc Func _ChordToOffset(ByRef $BMPHandle, $x,$y) Local $row=($BMPHandle[1]*3+$BMPHandle[0]) return 54+(($BMPHandle[2]*$row)-(($y+1)*$row)+($x*3)) EndFunc Func _Reverse8($inHex) Return StringMid($inHex,7,2)&StringMid($inHex,5,2)&StringMid($inHex,3,2)&StringMid($inHex,1,2) EndFunc1 point
-
I make few modyfications: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include-once #include <FileConstants.au3> ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.3.6.1 ; Author: Evilertoaster <evilertoaster at yahoo dot com> ; ; Script Function: ; Basic BMP file managment. ;Script Version: ; 3.3b with mLipok modyfications ; * CleanUp ; * #AutoIt3Wrapper_Au3Check_Parameters ; * Variable Names - UDF Standards ; * some minior changes ; * function renaming by add _BMP_ ; * ; ---------------------------------------------------------------------------- ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_Create ; Description ...: Creates a BMP 'Handle' to be used in later functions. The BMP dimensions will be decided by the parameters. ; Syntax.........: _BMP_Create($iWidth,$iHeight) ; Parameters ....: $iWidth - "" in pixels ; $iHeight - "" in pixels ; Return values .: Success - A BMP handle ; #FUNCTION# ==================================================================================================================== Func _BMP_Create($iWidth, $iHeight) Local $c = Mod($iWidth, 4) Local $d = Binary("") If $c = 3 Then $dSupplement = Binary("0x000000") If $c = 2 Then $dSupplement = Binary("0x0000") If $c = 1 Then $dSupplement = Binary("0x00") ; *** BMP header (54bytes total) *** Local $dHeader = Binary("0x424D" & _ ;2bytes, BM signature "00000000" & _ ;4bytes, filesize (optional, omitted) "0000" & _ ;2bytes, reserved "0000" & _ ;2bytes, reserved "36000000" & _ ;4bytes, offset to image data "28000000" & _ ;4bytes, BITMAPINFOHEADER __BMP_Reverse8(Hex($iWidth, 8)) & _ ;4bytes, bitmap width __BMP_Reverse8(Hex($iHeight, 8)) & _ ;4bytes, bitmap hieght "0100" & _ ;2bytes, bitmap planes "1800" & _ ;2bytes, bitmap bitdepth "00000000" & _ ;4bytes, bitmap compression type (none) __BMP_Reverse8(Hex(($iHeight) * _ ($iWidth) * 3 + ($iHeight * $c), 8)) & _ ;4bytes, bitmap data size "00000000" & _ ;4bytes, bitmap horizontal resolution (optional,omitted) "00000000" & _ ;4bytes, bitmap vertical resolution (optional,omitted) "00000000" & _ ;4bytes, bitmap colors (optional?, omitted) "00000000") ;4bytes, important colors (optional?, omitted) ; *** End BMP Header *** Local $dRowData = Binary("") For $n = 1 To $iWidth $dRowData &= Binary("0xFFFFFF") Next $dRowData &= $dSupplement Local $dImageData = Binary("") For $m = 1 To $iHeight $dImageData &= $dRowData Next Local $dBinaryData = $dHeader & $dImageData Local $aBMP_Handle[4] = [$c, $iWidth, $iHeight, DllStructCreate('ubyte[' & BinaryLen($dBinaryData) & ']')] DllStructSetData($aBMP_Handle[3], 1, $dBinaryData) Return $aBMP_Handle EndFunc ;==>_BMP_Create ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_Open ; Description ...: Creates a BMP 'Handle' from a BMP file. ; Syntax.........: _BMP_Open($Path) ; Parameters ....: $Path - Path to the file ; Return values .: Success - A BMP handle ; Failure - -1: FileOpen() returned -1 ; -2: Not a valid BMP file header ; -3: BMP file header has invalid hieght or width specified ; #FUNCTION# ==================================================================================================================== Func _BMP_Open($Path, $Progress = 1) #forceref $Progress Local $hBMP_File = FileOpen($Path, $FO_BINARY) If $hBMP_File = -1 Then Return -1 Local $dBMP_FileContents = FileRead($hBMP_File) FileClose($hBMP_File) If BinaryMid($dBMP_FileContents, 1, 2) <> "0x424D" Then Return -2 Local $iWidth = Dec(__BMP_Reverse8(Hex(BinaryMid($dBMP_FileContents, 19, 4)))) Local $iHeight = Dec(__BMP_Reverse8(Hex(BinaryMid($dBMP_FileContents, 23, 4)))) If $iWidth = 0 Or $iHeight = 0 Then Return -3 For $c = $iWidth To 0 Step -4 If $c < 4 Then ExitLoop Next Local $aBMP_Handle[4] = [$c, $iWidth, $iHeight, DllStructCreate('ubyte[' & BinaryLen($dBMP_FileContents) & ']')] DllStructSetData($aBMP_Handle[3], 1, $dBMP_FileContents) Return $aBMP_Handle EndFunc ;==>_BMP_Open ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_PixelRead ; Description ...: Returns the color at the pixel coordinate and BMPHandle given. ; Syntax.........: _BMP_PixelRead($aBMP_Handle,$X,$Y) ; Parameters ....: $aBMP_Handle - "" ; $X - X coordinate of the pixel ; $Y - Y coordinate of the pixel ; Return values .: Success - A Color as a hex string in RRGGBB format ; #FUNCTION# ==================================================================================================================== Func _BMP_PixelRead(ByRef $aBMP_Handle, $x, $y) If IsArray($aBMP_Handle) = False Or $x > $aBMP_Handle[1] - 1 Or $x < 0 Or $y > $aBMP_Handle[2] - 1 Or $y < 0 Then Return 0 Local $offset = __BMP_ChordToOffset($x, $y, $aBMP_Handle) Return Hex(DllStructGetData($aBMP_Handle[3], 1, $offset + 3), 2) & Hex(DllStructGetData($aBMP_Handle[3], 1, $offset + 2), 2) & Hex(DllStructGetData($aBMP_Handle[3], 1, $offset + 1), 2) EndFunc ;==>_BMP_PixelRead ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_PixelWrite ; Description ...: Writes the color to the pixel coordinate and BMPHandle given. ; Syntax.........: _BMP_PixelWrite($aBMP_Handle, $iX, $iY, $Color) ; Parameters ....: $aBMP_Handle - "" ; $iX - X coordinate of the pixel ; $iY - Y coordinate of the pixel ; $Color - A Color as a hex string in RRGGBB format (e.g. "AAFF00") ; Return values .: Success - Returns 1 ; #FUNCTION# ==================================================================================================================== Func _BMP_PixelWrite(ByRef $aBMP_Handle, $iX, $iY, $color) If $iX > $aBMP_Handle[1] - 1 Or $iX < 0 Or $iY > $aBMP_Handle[2] - 1 Or $iY < 0 Or StringLen($color) <> 6 Then Return 0 Local $offset = __BMP_ChordToOffset($iX, $iY, $aBMP_Handle) DllStructSetData($aBMP_Handle[3], 1, Dec(StringLeft($color, 2)), $offset + 3) DllStructSetData($aBMP_Handle[3], 1, Dec(StringMid($color, 3, 2)), $offset + 2) DllStructSetData($aBMP_Handle[3], 1, Dec(StringRight($color, 2)), $offset + 1) Return 1 EndFunc ;==>_BMP_PixelWrite ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_Write ; Description ...: Writes the BMP Handle $aBMP_Handle to the file path $sBMP_FileFullPath. ; Syntax.........: _BMP_Write($aBMP_Handle,$sBMP_FileFullPath) ; Parameters ....: $aBMP_Handle - "" ; $sBMP_FileFullPath - Path to the file; ; Return values .: Success - Returns 1 ; Failure - -1: FileOpen() returned -1 ; #FUNCTION# ==================================================================================================================== Func _BMP_Write(ByRef $aBMP_Handle, $sBMP_FileFullPath) If IsArray($aBMP_Handle) = False Then Return 0 Local $out = FileOpen($sBMP_FileFullPath, $FO_OVERWRITE + $FO_BINARY) If $out = -1 Then Return -1 FileWrite($out, DllStructGetData($aBMP_Handle[3], 1)) FileClose($out) Return 1 EndFunc ;==>_BMP_Write ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_GetWidth ; Description ...: Returns the width in pixels of the BMP. Same as $aBMP_Handle[1]. ; Syntax.........: _BMP_GetWidth($aBMP_Handle) ; Parameters ....: $aBMP_Handle - "" ; #FUNCTION# ==================================================================================================================== Func _BMP_GetWidth(ByRef $aBMP_Handle) If UBound($aBMP_Handle) <> 4 Then Return 0 Return $aBMP_Handle[1] EndFunc ;==>_BMP_GetWidth ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_GetHeight ; Description ...: Returns the Height in pixels of the BMP. Same as $aBMP_Handle[2]. ; Syntax.........: _BMP_GetHeight($aBMP_Handle) ; Parameters ....: $aBMP_Handle - "" ; #FUNCTION# ==================================================================================================================== Func _BMP_GetHeight(ByRef $aBMP_Handle) If UBound($aBMP_Handle) <> 4 Then Return 0 Return $aBMP_Handle[2] EndFunc ;==>_BMP_GetHeight ; #FUNCTION# ==================================================================================================================== ; Name...........: _BMP_PixelFill ; Description ...: Does a paint "fill" effect on the given pixel with the given color. It will also shade in pixels within the ; given shade variation (defualt 0 is exact match for pixel color, 1 would allow 1 shade lighter or darker than ; the starting pixel ect.). ; Syntax.........: _BMP_PixelFill($aBMP_Handle,$x,$y,$color[,$variation=0]) ; Parameters ....: $aBMP_Handle, $x, $y, $color see _BMP_PixelWrite() ; Return values .: Success - Returns the number of pixels filled ; #FUNCTION# ==================================================================================================================== Func _BMP_PixelFill(ByRef $aBMP_Handle, $x, $y, $color, $variation = 0) Local $aCheckChart[UBound($aBMP_Handle, 1)][UBound($aBMP_Handle, 2)] #forceref $aCheckChart Local $iCount = 0 Local $iTset = 1 Local $aTracer[$iTset] $aTracer[$iTset - 1] = $x & "," & $y Local $CheckColor = Dec(_BMP_PixelRead($aBMP_Handle, $x, $y)) $aCheckChart[$y][$x] = 1 Local $aPoint While 1 If Abs(Dec(_BMP_PixelRead($aBMP_Handle, $x - 1, $y)) - $CheckColor) <= $variation Then $aCheckChart[$x - 1][$y] = 1 $iCount += 1 _BMP_PixelWrite($aBMP_Handle, $x - 1, $y, $color) $iTset += 1 ReDim $aTracer[$iTset] $aTracer[$iTset - 1] = $x & "," & $y $x = $x - 1 ContinueLoop EndIf If Abs(Dec(_BMP_PixelRead($aBMP_Handle, $x, $y - 1)) - $CheckColor) <= $variation Then $aCheckChart[$x][$y - 1] = 1 $iCount += 1 _BMP_PixelWrite($aBMP_Handle, $x, $y - 1, $color) $iTset += 1 ReDim $aTracer[$iTset] $aTracer[$iTset - 1] = $x & "," & $y $y = $y - 1 ContinueLoop EndIf If Abs(Dec(_BMP_PixelRead($aBMP_Handle, $x + 1, $y)) - $CheckColor) <= $variation Then $aCheckChart[$x + 1][$y] = 1 $iCount += 1 _BMP_PixelWrite($aBMP_Handle, $x + 1, $y, $color) $iTset += 1 ReDim $aTracer[$iTset] $aTracer[$iTset - 1] = $x & "," & $y $x = $x + 1 ContinueLoop EndIf If Abs(Dec(_BMP_PixelRead($aBMP_Handle, $x, $y + 1)) - $CheckColor) <= $variation Then $aCheckChart[$x][$y + 1] = 1 $iCount += 1 _BMP_PixelWrite($aBMP_Handle, $x, $y + 1, $color) $iTset += 1 ReDim $aTracer[$iTset] $aTracer[$iTset - 1] = $x & "," & $y $y = $y + 1 ContinueLoop EndIf $aPoint = StringSplit($aTracer[$iTset - 1], ",") $x = $aPoint[1] $y = $aPoint[2] $iTset -= 1 ReDim $aTracer[$iTset] If $iTset = 1 Then ExitLoop WEnd Return $iCount EndFunc ;==>_BMP_PixelFill Func __BMP_ChordToOffset($x, $y, ByRef $aBMP_Handle) Local $row = ($aBMP_Handle[1] * 3 + $aBMP_Handle[0]) Return 54 + (($aBMP_Handle[2] * $row) - (($y + 1) * $row) + ($x * 3)) EndFunc ;==>__BMP_ChordToOffset Func __BMP_Reverse8($inHex) Return StringMid($inHex, 7, 2) & StringMid($inHex, 5, 2) & StringMid($inHex, 3, 2) & StringMid($inHex, 1, 2) EndFunc ;==>__BMP_Reverse81 point