All I want is to take a hex value, split it up from AARRGGBB to Red := RR, Green := GG, Blue := BB then convert that to dec
ff = 255
Then with another value, take the dec, convert to hex and repeat the steps above.
Code: Select all
;__________________________________________________________________________________
msgbox, % sRed := SubStr( SearchColor, 5, 2) ;Should be "FF" or something like the (a 2 digit hex value)
msgbox, % sRed := Dec( sRed ) ;Should be "255" or something like that
;__________________________________________________________________________________
color := "Dec Number" ;336763294623
color := Hex( color ) ;0xFFFFFFFF
cRed := SubStr( SearchColor, 5, 2) ;"FF"
cRed := Dec( cRed ) ;255
Source code
Code: Select all
SetPixels( ByRef pBitmap , obj , SearchColor , ReplaceColor , Tolerance := 0 ){
sRed := SubStr( SearchColor, 5, 2)
sGreen := SubStr( SearchColor, 7, 2)
sBlue := SubStr( SearchColor, 9, 2)
sRed := "0x" sRed , sGreen := "0x" sGreen , sBlue := "0x" sBlue
sRed := sRed+0 , sGreen := sGreen+0 , sBlue := sBlue+0
y := obj.Y
;~ sRed := sRed+0 , sGreen := sGreen+0 , sBlue := sBlue+0
Loop, % obj.H {
x := obj.X
Loop, % obj.W {
SetFormat, IntegerFast, hex
col := Gdip_GetPixel( pBitmap, x , y )
;~ MsgBox, % col
cRed := SubStr( col, 5, 2)
cGreen := SubStr( col, 7, 2)
cBlue := SubStr( col, 9, 2)
SetFormat, IntegerFast, dec
sRed := sRed+0 , sGreen := sGreen+0 , sBlue := sBlue+0
;~ cRed := "0x" cRed , cGreen := "0x" cGreen , cBlue := "0x" cBlue
cRed := cRed+0 , cGreen := cGreen+0 , cBlue := cBlue+0
;~ MsgBox, % cRed " " sRed "`n" cGreen " " sGreen "`n" cBlue " " sBlue
if( col = SearchColor || ( cRed >= ( sRed - Tolerance ) && cRed <= ( sRed + Tolerance ) && cGreen >= ( sGreen - Tolerance ) && cGreen <= ( sGreen + Tolerance ) cBlue >= ( sBlue - Tolerance ) && cBlue <= ( sBlue + Tolerance ) ) ){
Gdip_SetPixel( pBitmap , x , y , ReplaceColor )
MsgBox, % cRed " " sRed "`n" cGreen " " sGreen "`n" cBlue " " sBlue
}
x++
}
y++
}
;~ SetFormat, IntegerFast, dec
}
*Note* I did try Format https://www.autohotkey.com/docs/commands/Format.htm, but have no love.