Attached script should produce a (light) turquoise rectangle inside
another turquoise rectangle. Unfortunately, it produces a grey rectangle
inside a black rectangle.

Willi

#!/usr/bin/perl
#
#
#
use strict;
use Image::Magick;

# read original image
my $orig = Image::Magick->new(size=>'384x256');
$orig->ReadImage('xc:white');
#my $w = $orig->Read('rose:');
#warn("$w")  if $w;
#exit  if $w =~ /^Exception/;


# make a clone of the image for modifications
#my $dest = $orig->Clone();

# You could enlarge destination image here if you like.

# Iterate over destination image...
my ($width, $height) = $orig->Get('width', 'height');

for( my $j = 10; $j < $height-10; $j++ ) {
  for( my $i = 10; $i < $width-10; $i++ ) {

    # write pixel to destination
    # (quantization and clipping happens here)
    $orig->SetPixel(x=>$i,y=>$j,color=>[0,1,1]);
  }
}

for( my $j = 20; $j < $height-20; $j++ ) {
  for( my $i = 20; $i < $width-20; $i++ ) {

    # write pixel to destination
    # (quantization and clipping happens here)
    $orig->SetPixel(x=>$i,y=>$j,color=>[0.5,1,1]);
  }
}


# display the result (or you could save it)
$orig->Display();

Reply via email to