Color of a screen pixel: Difference between revisions
Content deleted Content added
Added Commodore BASIC |
SqrtNegInf (talk | contribs) Added Perl example |
||
Line 694:
echo getPixelColor(0, 0)</lang>
=={{header|Perl}}==
This example works with MacOS, customize with the appropriate <tt>screencapture</tt> utility for other OSes.
<lang perl>use strict;
use warnings;
use GD;
my $file = '/tmp/one-pixel-screen-capture.png';
system "screencapture -R 123,456,1,1 $file";
my $image = GD::Image->newFromPng($file);
my $index = $image->getPixel(0,0);
my($red,$green,$blue) = $image->rgb($index);
print "RGB: $red, $green, $blue\n";
unlink $file;</lang>
{{out}}
<pre>RGB: 20, 2, 124</pre>
=={{header|Phix}}==
|