Listing 6. Overlaying the UC icons on the cropped image
# Load the icon file
#
use constant ICON_FILE => 'icon.png';
my $fh = new FileHandle( ICON_FILE );
unless ($fh) { die "Cannot open UC icon file ", ICON_FILE; }
flock( $fh, LOCK_SH );
$ImgIcon = GD::Image->newFromPng( $fh );
flock( $fh, LOCK_UN );
close( $fh );
# Make sure icon's yellow is in pallette!
#
$ImgCrop->colorAllocate(255, 222, 0);
my ($x_left, $y_top, $x_right, $y_bottom) =
getZoomedInCoords( getImageMapCoords() );
my @Locations = getIconLocationsByCoords($x_left, $y_top, $x_right, $y_bottom);
# For each returned project location overlay a UC icon on the map.
# (Note that we do not check to see if icons overlap, because of the
# way we store location infromation in the Map table.)
#
foreach my $ref ( @Locations ) {
$ImgCrop->copy( $ImgIcon,
$ref->{X} - $x_left - HALF_ICON,
$ref->{Y} - $y_top - HALF_ICON,
0, 0, ICON_DIM, ICON_DIM );
}