Sign in to follow this  
Followers 0
rebelcitymogo

Bug in pixel colour functionality

14 posts in this topic

Red pixel comes out to be blue and blue pixel comes out to be red!

Share this post


Link to post
Share on other sites



Red pixel comes out to be blue and blue pixel comes out to be red!

No, it doesn't. More likely, you have misinterpreted the 24-bit RGB value.

If you still think it does, post a short demo script that reproduces the error.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I set out to prove the guy wrong... So I hovered over the Blue section of the forums, and took a PixelGetColor and converted it to hex using...

Hex("9886198") ; The color found... and he's right... It's red?

I used the RGB/Hex converter here to have the color displayed for me...

http://www.web-wise-wizard.com/html-tutori...-converter.html

Reproduction:

HotkeySet("{ENTER}","Testicles")
While 1
    $Color = Hex(PixelGetColor(MouseGetPos(1),MouseGetPos(2)))
    TrayTip("Color",$Color,5)
WEnd
Func Testicles()
    ClipPut($Color)
EndFunc
Edited by BinaryBrother

Share this post


Link to post
Share on other sites

Please temme a way out because i need this solution urgently!!

Share this post


Link to post
Share on other sites

from my experience the b and r components are mixed or refrenced opposite to what they should be..

since i m getting colour of thesame pixel thru c# where the r and b components are exactly opposite.

It works fine for black and green .. yellow gives aqua , red gives blue and blue gives red and hence every colour tht has blue and red ..the r and b are opposite

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Aha... Looks like PixelGetColor is returning BGR instead of RGB... ^_^

Although the latest version of AutoIt, which I have... Is supposed to use RGB by default, and documentation for "Opt(ColorMode,opt)" is missing... So I would assume that this might actually be a bug... ;)

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The problem is not PixelGetColor(), it is your MouseGetPos():

HotkeySet("{ESC}","_Quit")

While 1
    Sleep(100)

    $iX_A = MouseGetPos(0)
    $iY_A = MouseGetPos(1)
    $iColorA = PixelGetColor($iX_A, $iY_A)
    $sColorA = "0x" & Hex($iColorA, 6)
    
    $iX_B = MouseGetPos(1)
    $iY_B = MouseGetPos(2)
    $iColorB = PixelGetColor($iX_B, $iY_B)
    $sColorB = "0x" & Hex($iColorB, 6)
    
    TrayTip("Color", "$iX_A = " & $iX_A & @LF & _
            "$iY_A = " & $iY_A & @LF & _
            "$iColorA = " & $iColorA & @LF & _
            "$sColorA = " & $sColorA & @LF & _
            @LF & _
            "$iX_B = " & $iX_B & @LF & _
            "$iY_B = " & $iY_B & @LF & _
            "$iColorB = " & $iColorB & @LF & _
            "sColorB = " & $sColorB, 5)
WEnd

Func _Quit()
    Exit
EndFunc

It not the wrong color, it's the wrong pixel. MouseGetPos(0) returns X, MouseGetPos(1) returns Y, and MouseGetPos(2) is invalid.

^_^

Edit: Tweaked demo to reflect good/bad parameters from the same method.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

m not using any of the above:

i think ur correct wen u say it returns BGR instead of RGB

Share this post


Link to post
Share on other sites

butthis will take me long time to manipulate andlot of extra code now.. so m using c# ..

simply taking a screen dump and using get pixel method..

Share this post


Link to post
Share on other sites

m not using any of the above:

i think ur correct wen u say it returns BGR instead of RGB

No, it does not. Unless you are using a VERY old version of AutoIt. Exactly what code are you getting the color with?

Did you run my demo above? What numbers did you get (from the $sColorA value that uses the correct method)?

Post a demo that shows what your issue is.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hey PsaltyDS, I've got something interesting here...

The above code is working now... I uninstalled everything, and reinstalled it... Somehow, my last upgrade didn't go over so well... I've been using the old version of AutoIt since December... I dunno how that happened... I noticed that the @CPUArch macro wasn't highlighting right in my SciTe, but I had updated documentation... So I decided to see if a reinstall would fix, and it did... It also fixed the RGB, BGR issue... ^_^

Share this post


Link to post
Share on other sites

MsgBox(0, "", @AutoItVersion)
:-)

salty - we build big wall

You bang head against one side

Others bang head against the other side

We see who gets headache first :-)

Good catch!

@BinaryBrother,

I've had the same thing happen and I too went months without noticing it until a script would not work for me like it did others in the forum :-(


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Hey PsaltyDS, I've got something interesting here...

The above code is working now... I uninstalled everything, and reinstalled it... Somehow, my last upgrade didn't go over so well... I've been using the old version of AutoIt since December... I dunno how that happened... I noticed that the @CPUArch macro wasn't highlighting right in my SciTe, but I had updated documentation... So I decided to see if a reinstall would fix, and it did... It also fixed the RGB, BGR issue... ;)

RGB color format has been the default since 2004! From the change log:

3.0.102 (4th August, 2004) (Release)

- Major Change: Colors now default to the standard RGB format rather than the previous BGR format.

This affects PixelSearch, PixelGetColor.

The "ColorMode" option has been added to allow old scripts to run with the old BGR mode, just

place this line at the top of your script to use the old method:

Opt("ColorMode", 1)

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0