#!/usr/bin/perl
#
# Name:
#	im-hax-get-set-pixel-1.pl.
#
# Purpose:
#	Demonstrate GetPixel and SetPixel methods.
#
# V 1.00 01-May-2002
# ------------------
# o Initial version
#
# Test environment:
#	OS: WinNT 4 SP 6a
#	Web server: Apache V 1.3.26
#	IM: V 5.4.7
#
# Input files:
#	None
#
# Output files:
#	None
#
# Note:
#	o tab = 4 spaces || die.
#	o Text reformatted to max 50 chars wide
#		so source can be converted to PDF
#
# Author:
#	Ron Savage <ron@savage.net.au>
#	http://savage.net.au/ImageMagick.html
#
# Licence:
#	Copyright (c) 1999-2002 Ron Savage
#
#	All Programs of mine are
#	'OSI Certified Open Source Software';
#	you can redistribute them and/or modify them
#	under the terms of the Artistic License,
#	a copy of which is available at:
#	http://www.opensource.org/licenses/index.html

use strict;
use warnings;

use Image::Magick;

# --------------------------------------------

my($im_version) = $Image::Magick::VERSION;

print "Image::Magick V $im_version. \n";
print "\n";

my($image)	=
	Image::Magick -> new(size => '10x10');
my($result)	= $image -> Read('xc:white');
die $result if $result;

$result = $image -> Draw
(
	primitive	=> 'path',
	stroke		=> 'red',
	points		=> 'M0,0 L9,9',
);
die $result if $result;

my(@pixel)	=  # Should be red.
	split(/,/, $image -> Get('Pixel[0,0]') );
my(@color)	= ('Red', 'Green', 'Blue', 'Alpha');

print 'Pixel [0,0]: ',
	(map{"$color[$_]: $pixel[$_]. "} 0 .. 3),
	"Red = 65535, 0, 0. \n";
@pixel	= # Should be white.
	split(/,/, $image -> Get('Pixel[9,0]') );
print 'Pixel [9,0]: ',
	(map{"$color[$_]: $pixel[$_]. "} 0 .. 3),
	"White = 65535, 65535, 65535. \n";
