sub Image { my $self = shift; if (($#_ != 0) and ($#_ != 2) and ($#_ != 4)) { _croak "ERROR: Wrong number of parameters!\n"; return undef; } my ($width, $height) = (0, 0); if (($#_ == 2) or ($#_ == 4)) { my ($fileorref, $x, $y, $w, $h) = @_; if (!_IsNo($fileorref)) { $fileorref = $self->Image($fileorref); unless (defined($fileorref)) { return undef; } } _GetEnhSize($self->{dc}, $fileorref, $width, $height, $self->{unit}); $width = $self->_xp2un($width); $height = $self->_yp2un($height); if ((!defined($w)) or ($w == 0)) { $w = $width; } if ((!defined($h)) or ($h == 0)) { $h = $height; } unless (_PlayEnhMetaFile($self->{dc}, $fileorref, $self->_xun2p($x), $self->_yun2p($y), $self->_xun2p($x + $w), $self->_yun2p($y + $h))) { _croak "ERROR: Cannot display metafile! ${\_GetLastError()}"; return undef; } return wantarray ? ($fileorref, $width, $height) : $fileorref; } else { my $file = shift; if (_IsNo($file)) { _GetEnhSize($self->{dc}, $file, $width, $height, $self->{unit}); $width = $self->_xp2un($width); $height = $self->_yp2un($height); return ($width, $height); } if (defined($self->{imagef}->{$file})) { _GetEnhSize($self->{dc}, $self->{imagef}->{$file}, $width, $height, $self->{unit}); $width = $self->_xp2un($width); $height = $self->_yp2un($height); return wantarray ? ($self->{imagef}->{$file}, $width, $height) : $self->{imagef}->{$file}; } my $fref; if ($file =~ /.emf$/) { $fref = _GetEnhMetaFile($file); unless ($fref) { _croak "ERROR: Cannot load metafile! ${\_GetLastError()}"; return undef; } } elsif ($file =~ /.wmf$/) { $fref = _GetWinMetaFile($self->{dc}, $file); unless ($fref) { _croak "ERROR: Cannot load metafile! ${\_GetLastError()}"; return undef; } } else { $fref = _LoadBitmap($self->{dc}, $file, -1, $self->{unit}); unless ($fref) { _croak "ERROR: Cannot load bitmap! ${\_GetLastError()}"; return undef; } } $self->{imager}->{$fref} = $file; $self->{imagef}->{$file} = $fref; _GetEnhSize($self->{dc}, $fref, $width, $height, $self->{unit}); $width = $self->_xp2un($width); $height = $self->_yp2un($height); return wantarray ? ($fref, $width, $height) : $fref; } }