At 5:25 pm -0300 27/01/03, Ricardo Montiel wrote:
A code example of how to read the value of a pixel would be great -
basically is what I don't know how to code.
Your friends here are located in QuickDraw.pm:

SetCPixel H, V, COLOR;
GetCPixel H, V;

COLOR is defined as:

$col = new RGBColor(RED, GREEN, BLUE);

where RED, GREEN, BLUE are unsigned 16 bit numbers written either as decimal or hexadecimal e.g.'OxABCD' (or decimal 43981).

H, V are the horizontal and vertical co-ordinates of the point in pixels.

From 'GetCPixel' you can determine (say) the red component of the point (100, 200) as:

$red = GetCPixel(100, 200)->red;

which will return you a number in the range 0 to FFFF.

To do all this you will obviously need to create a MacWindow and put your picture into it. First however you will have to convert the picture into a 'PICT' format.

If you want a MacPerl script to convert (more or less) any picture format into a 'PICT' I can send you a script to do this. The script sends AppleEvents to GraphicConverter (which is not so easy and straightforward as it might sound).

If you need any assistance to create a MacPerl window into which to paste your picture I suggest you look at DialogBuilder which you can download from:

http://www.afco.demon.co.uk

which will help you build you an appropriate MacPerl window fairly painlessly.

If you need any tips on pasting a 'PICT' into a MacPerl window I can send you a 'tutorial' script detailing the procedure.

I hope this is germane to your project and will be of some help. Do let me know if I can be of any further assistance.

Alan Fry


Reply via email to