c:>type gp1.pl use Imager; my $image_source = "\\c\\perl\\graphics\\" . shift . ".bmp"; my $image = Imager->new; $image->read(file=>$image_source) or die "Cannot load $image: ", $image->errstr; $width = $image->getwidth(); $height = $image->getheight(); print "Image dimensions: height = $height, width = $width\n"; $x = 10; for $y ( 10 .. 15 ) { $color = $image->getpixel( x=>$x, y=>$y, type=>'8bit' ); ( $r, $g, $b, $a ) = $color->rgba(); print " shade = $r, $g, $b\n"; } c:>gp1 d2044 Image dimensions: height = 348, width = 349 shade = 238, 238, 238 shade = 255, 255, 255 shade = 255, 255, 255 shade = 238, 238, 238 shade = 238, 238, 238 shade = 238, 238, 238 c:> #### c:>type gp2.pl use Imager; my $image_source = "\\c\\perl\\graphics\\" . shift . ".bmp"; my $image = Imager->new; $image->read(file=>$image_source) or die "Cannot load $image: ", $image->errstr; $width = $image->getwidth(); $height = $image->getheight(); print "Image dimensions: height = $height, width = $width\n"; $x = 10; for $y ( 10 .. 15 ) { ( $r, $g, $b, $a ) = $image->getpixel( x=>$x, y=>$y, type=>'8bit' )->rgba(); print " shade = $r, $g, $b\n"; } c:>gp2 d2044 Image dimensions: height = 348, width = 349 shade = 238, 238, 238 shade = 255, 255, 255 shade = 255, 255, 255 shade = 238, 238, 238 shade = 238, 238, 238 shade = 238, 238, 238 #### c:>type gp3.pl use Imager; my $image_source = "\\c\\perl\\graphics\\" . shift . ".bmp"; my $image = Imager->new; $image->read(file=>$image_source) or die "Cannot load $image: ", $image->errstr; $width = $image->getwidth(); $height = $image->getheight(); print "Image dimensions: height = $height, width = $width\n"; $x = 10; $y = [ 10 .. 15 ]; @colors = $image->getpixel( x=>$x, y=>$y, type=>'8bit' ); for $color ( @colors ) { ( $r, $g, $b, $a ) = $color->rgba(); print " shade = $r, $g, $b\n"; } c:>gp3 d2044 Image dimensions: height = 348, width = 349 Can't call method "rgba" on an undefined value at gp3.pl line 15. #### c:>type gp4.pl use Imager; my $image_source = "\\c\\perl\\graphics\\" . shift . ".bmp"; my $image = Imager->new; $image->read(file=>$image_source) or die "Cannot load $image: ", $image->errstr; $width = $image->getwidth(); $height = $image->getheight(); print "Image dimensions: height = $height, width = $width\n"; $x = [ 10 ]; $y = [ 10 .. 15 ]; @colors = $image->getpixel( x=>$x, y=>$y, type=>'8bit' ); for $color ( @colors ) { ( $r, $g, $b, $a ) = $color->rgba(); print " shade = $r, $g, $b\n"; } c:>gp4 d2044 Image dimensions: height = 348, width = 349 Can't call method "rgba" on an undefined value at gp4.pl line 15.