Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > Non-IR Operations >

Image/Pixel-Color Operations

GPC. - Get-Pixel-Colour

Previous Top Next


MiniRobotLanguage (MRL)

 

GPC. Command

Get Pixel Color

 

 

Intention

 

This command reads the screen color of a pixel in a window. You can specify coordinates in Screen- (desktop), or in window-coordinates.

 

You will also get the  red, green and blue parts of the color (in this order) on the Stack.

 

In the simplest way you can check the Pixel-color at some point like this:

 

GPC.624,794

STS.DUMP

 

And this is what you may find on TOS.

 

graphic

 

 

First on Top, the 24-bit color value. Then next, the Blue-($$001),Green-($$002), and the Red ($$003)-Part of the Pixel-color.

If you just need the color value, you can get it using the $$000 Stackvariable.

 

GPC.624,794

PRT.The 24-bit color is: $$000

STS.DUMP

MBX.!

 

Or you can just add one Parameter with a variable. The following Sample shows it. And it also shows that you can use a Point-Variable instead of two coordinated here.

 

VAP.$$COR=624,794

GPC.$$COR|$$COL

PRT.The 24-bit color is: $$COL

STS.DUMP

MBX.!

ENR.

 

 

 

 

Syntax

 

 

GPC.[P1][|P2]

GPC.[proto]|P1,P2

 

 

 

 

Parameter Explanation

 

P1 - (optional) prototype coordinates

P2 - (optional) coordinates separated with ","

P3 - (optional) takes the pixel-colour, if omitted stack is used.

 

There are three prototypes:

- c - Childwindow Coordinates (you can use "o" for this one also.)

- a - actual window coordinates

- t - Top-Window Coordinates

If prototype is omitted, Screen-Coordinates are taken.

 

 

 

Example

 

'***********************************

' GPC.-Demo

'***********************************

GPC.1028,1370

STS.DUMP

$$COL=$$000

VTH.$$COL

PRT.The 24-bit color is: $$COL

MBX.!

END.

 

'***********************************

' GPC.-Demo

'***********************************

JSR.closeNotepads

EXO.notepad

STW.p|#pid#

SCW.c|edit

MMV.o|50,100

STS.CLEAR

' Get colour from Child-Window-Coord's

VAP.§§AAA=50,100

GPC.c|§§AAA

JSR.showcol

 

' Get colour from Top-Window-Coord's

VAP.§§AAA=50,100

GPC.t|§§AAA

JSR.showcol

 

' Get Screen-Color

VAP.§§AAA=50,100

GPC.s|§§AAA

JSR.showcol

MBX.!

 

' Get Screen-Color and show Stack-Order

VAP.§§AAA=50,100

GPC.s|§§AAA

STS.DUMP

MBX.!

 

' Show Speed-Dump

DMP.

 

MBX.!

END.

 

:showcol

PRT.----------------------

PRT. Red is: $$003

PRT. Green is: $$002

PRT. Blue is: $$001

$$COL=$$000

VTH.$$COL

PRT. Pixel-Color is: $$COL

PRT.----------------------

RET.

 

:closeNotepads

STW.ctwo|notepad|Editor|0|overcn

CLW.

JMP.closeNotepads

:overcn

RET.

 

 

 

Remarks

 

Instead of using separate variables for X and Y, you can also use a Point-Variable, where x and y values are separated by a "," as follows:

 

VAR.§§PAP=10,10

GPC.§§PRE|§§PAP|§§COL

 

 

Limitations:

 

The RGB-Splitter works default with 24- or 32 bit colors. It will not work with 8 or 16 bit color depth.

 

 

 

See also:

 

    1.8. Selecting the Application (Topwindow)

    IPC. / NPC. - If-Pixel-Colour

    SPC. -Set-Pixel-Colour