Sign in to follow this  
Followers 0
gil900

open a png file and read the color of a particular pixel?

5 posts in this topic

#1 ·  Posted (edited)

I want to open a png file and read the color of a particular pixel.

I found that someone wrote this for bmp files:

; #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)

But I prefer to work on a png or jpg..

Edited by gil900

Share this post


Link to post
Share on other sites



Why not use PixelGetColor? That will work on a png.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

what logan is suggesting i think is to forget about the file type. PixelGetColor() works with anything - the png has been opened and is visible on the desktop, so PixelGetColor() will work. look at the example code

also see PixelCoordMode() under AutoItSetOption

if you're wanting to get the color based on mouse position, see MouseGetPos()


FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

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