Hospital

how would you capture pixels in a region?

5 posts in this topic

can someone help me here?

have been trying to figure out how to list all the different colors in a certain region to an array?

how would I do this? thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this:
 

#include <Array.au3>

Global $TopLeftX = 0
Global $TopLeftY = 0

Global $BotRightX = 10
Global $BotRightY = 10

Global $Array[1] = [0]

For $i = $TopLeftX To $BotRightX
    For $j = $TopLeftY To $BotRightY
        $Array[0] += 1
        ReDim $Array[$Array[0] + 1]
        $Array[$Array[0]] = "Color on coordinate X:" & $i & "/Y:" & $j & " - " & PixelGetColor($i, $j)
    Next
Next

_ArrayDisplay($Array)

What you need is basically two points on your screen, one on the top left and one of the bottom right that would mark a rectangle.
Just replace the values in the first four variables.
 

Edited by Radiance

Share this post


Link to post
Share on other sites

Radiance,

ReDim is one of the slowest functions in AutoIt, especially when it comes to large arrays, so calling it within a loop as you do is really slowing the script. As you know the size of the area to be stored why not size the array correctly beforehand - or even better use a 2D array so that the array indices reflect the coordinates of the point stored within?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba23,

I did not know that. Here's my updated script.
Pretty slow when the rectangle gets bigger but that might be the PixelGetColor func.

#include <Array.au3>

Global $TopLeftX = 0
Global $TopLeftY = 0

Global $BotRightX = 10
Global $BotRightY = 10

Global $Array[$BotRightX - $TopLeftX + 1][$BotRightY - $TopLeftY + 1]

For $i = 0 To UBound($Array) - 1
    For $j = 0 To UBound($Array, 2) - 1
        $Array[$i][$j] = PixelGetColor($TopLeftX + $i, $TopLeftY + $j)
    Next
Next

_ArrayDisplay($Array)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Melba23,

I did not know that. Here's my updated script.
Pretty slow when the rectangle gets bigger but that might be the PixelGetColor func.

#include <Array.au3>

Global $TopLeftX = 0
Global $TopLeftY = 0

Global $BotRightX = 10
Global $BotRightY = 10

Global $Array[$BotRightX - $TopLeftX + 1][$BotRightY - $TopLeftY + 1]

For $i = 0 To UBound($Array) - 1
    For $j = 0 To UBound($Array, 2) - 1
        $Array[$i][$j] = PixelGetColor($TopLeftX + $i, $TopLeftY + $j)
    Next
Next

_ArrayDisplay($Array)

What would be the fastest way to not list the same pixel, without writing each one down to notepad and scanning down the document to see if it's already there?

Thank you guys appreciate it.

/edit, i got it.

now i'm working on the gui with artifical pixels

 

Edited by Hospital

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