version 1.78, 2005/06/28 14:58:23
|
version 1.79, 2005/07/14 04:08:55
|
Line 369 sub get_label_width {
|
Line 369 sub get_label_width {
|
|
|
|
|
} |
} |
|
|
|
sub get_label_height { |
|
my $label = shift; |
|
&Apache::lonxml::debug("image label = $label"); |
|
if (-e $label) { |
|
&Apache::lonxml::debug("$label exists"); |
|
} else { |
|
&Apache::lonxml::debug("$label does not exist"); |
|
} |
|
my $magick = Image::Magick->new; |
|
$magick->Read($label); |
|
my $pixel_height = $magick->Get('height'); |
|
return $pixel_height * $scale_factor; |
|
} |
|
|
sub add_vars { |
sub add_vars { |
my ($name,$order,$label,$labelorder,$value,$image,$safeeval) = @_; |
my ($name,$order,$label,$labelorder,$value,$image,$safeeval) = @_; |
if (!defined($name) || $name eq '') { return; } |
if (!defined($name) || $name eq '') { return; } |
Line 446 sub end_labelgroup {
|
Line 461 sub end_labelgroup {
|
#y latex coordinate |
#y latex coordinate |
# my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 ); |
# my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 ); |
my $tcY=$height_param-$y*($height_param/$wheight); |
my $tcY=$height_param-$y*($height_param/$wheight); |
|
if ( $type eq 'image') { |
|
my $label_height = &get_label_height($label); |
|
$tcY=$tcY-$label_height; |
|
} |
|
|
&Apache::lonxml::debug("hparam = $height_param wheight = $wheight texy = $tcY"); |
&Apache::lonxml::debug("hparam = $height_param wheight = $wheight texy = $tcY"); |
$tcX=sprintf('%.2f',$tcX); |
$tcX=sprintf('%.2f',$tcX); |
$tcY=sprintf('%.2f',$tcY); |
$tcY=sprintf('%.2f',$tcY); |
Line 456 sub end_labelgroup {
|
Line 476 sub end_labelgroup {
|
} elsif ( $type eq 'image') { |
} elsif ( $type eq 'image') { |
my ($path,$file) = &Apache::londefdef::get_eps_image($label); |
my ($path,$file) = &Apache::londefdef::get_eps_image($label); |
my $image_name = $path.$file; |
my $image_name = $path.$file; |
my $label_width = get_label_width($label); |
my $label_width = &get_label_width($label); |
|
|
$result .= '\includegraphics[width='.$label_width.'mm]{' |
$result .= '\includegraphics[width='.$label_width.'mm]{' |
.$image_name."}}\n"; |
.$image_name."}}\n"; |