Why ARGB convert to RGB with missing "Number0" ? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fiendhunter
Posts: 140
Joined: 24 Jul 2019, 15:27

Why ARGB convert to RGB with missing "Number0" ?

Post by fiendhunter » 16 May 2022, 07:20

I have 2 color to convert RGB;
FF23352A it returns 0x23352A
but FF05110A it returns 0x5110A

Code: Select all

SetFormat, Integer, H
pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromHBITMAP(HSplashScreenChoose)
ARGB := Gdip_GetPixel( pBitmap, 283, 53 )                                ; ARGB := FF05110A
RGB := ARGB & 0xffffff
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
SetFormat, Integer, D
msgbox % RGB
return
am I missing someting? I search for this issue. All answers; 5110A and 05110A are same (but 5110A is not work for lateron :)

User avatar
mikeyww
Posts: 27095
Joined: 09 Sep 2014, 18:38

Re: Why ARGB convert to RGB with missing "Number0" ?  Topic is solved

Post by mikeyww » 16 May 2022, 07:29

You are not missing something. As you noted, the numbers are the same. You can add leading zeroes if needed for some uses.

Code: Select all

For each, argb in [0xFF23352A, 0xFF05110A]
 MsgBox, 0, Colors, % "ARGB = " Format("{:06x}", argb) "`n`n RGB = " Format("{:06x}", argb & 0xFFFFFF)

fiendhunter
Posts: 140
Joined: 24 Jul 2019, 15:27

Re: Why ARGB convert to RGB with missing "Number0" ?

Post by fiendhunter » 16 May 2022, 07:46

mikeyww wrote:
16 May 2022, 07:29
You are not missing something. As you noted, the numbers are the same. You can add leading zeroes if needed for some uses.

Code: Select all

For each, argb in [0xFF23352A, 0xFF05110A]
 MsgBox, 0, Colors, % "ARGB = " Format("{:06x}", argb) "`n`n RGB = " Format("{:06x}", argb & 0xFFFFFF)
Thy. it works well. I ll check "Format" for more.

curious...

Code: Select all

StringTrimLeft, RGBval,  ARGB, 4
can output abnormal value? or identicle same as

Code: Select all

RGBval := Format("{:06x}", argb & 0xFFFFFF)

User avatar
mikeyww
Posts: 27095
Joined: 09 Sep 2014, 18:38

Re: Why ARGB convert to RGB with missing "Number0" ?

Post by mikeyww » 16 May 2022, 08:16

You can answer that question by testing a few values with which you are already working. The answer will, I believe, depend on whether you are working with numbers that always have exactly the same number of characters.

fiendhunter
Posts: 140
Joined: 24 Jul 2019, 15:27

Re: Why ARGB convert to RGB with missing "Number0" ?

Post by fiendhunter » 16 May 2022, 08:42

mikeyww wrote:
16 May 2022, 08:16
You can answer that question by testing a few values with which you are already working. The answer will, I believe, depend on whether you are working with numbers that always have exactly the same number of characters.
My all tests, output same value. but I wont trust the results. RGBval := Format("{:06x}", argb & 0xFFFFFF) is working well with no question :)

thank you again.

User avatar
mikeyww
Posts: 27095
Joined: 09 Sep 2014, 18:38

Re: Why ARGB convert to RGB with missing "Number0" ?

Post by mikeyww » 16 May 2022, 08:51

I guess you would need to test something with a small "A" value, but OK if the current approach works. Enjoy!

Post Reply

Return to “Ask for Help (v1)”