Bio-Graphics

 view release on metacpan or  search on metacpan

lib/Bio/Graphics/Glyph/image.pm  view on Meta::CPAN

  return $self;
}

sub get_image {
  my $self    = shift;
  my ($format,$image)   = eval { $self->image_data };
  unless ($image) {
    warn $@ if $@;
    return;
  }
  my $gd      =   $format eq 'image/png'  ? GD::Image->newFromPngData($image,1)
                : $format eq 'image/jpeg' ? GD::Image->newFromJpegData($image,1)
		: $format eq 'image/gif'  ? GD::Image->newFromGifData($image)
		: $format eq 'image/gd'   ? GD::Image->newFromGdData($image)
		: $format eq 'image/gd2'  ? GD::Image->newFromGd2Data($image)
		: $self->throw("This module cannot handle images of type $format");
  return $gd;
}

sub _guess_format {
  my $self = shift;

lib/Bio/Graphics/Panel.pm  view on Meta::CPAN

}

# draw an image (or invoke a drawing routine)
sub draw_background {
  my $self = shift;
  my ($gd,$image_or_routine) = @_;
  if (ref $image_or_routine eq 'CODE') {
    return $image_or_routine->($gd,$self);
  }
  if (-f $image_or_routine) { # a file to draw
    my $method = $image_or_routine =~ /\.png$/i   ? 'newFromPng'
               : $image_or_routine =~ /\.jpe?g$/i ? 'newFromJpeg'
               : $image_or_routine =~ /\.gd$/i    ? 'newFromGd'
               : $image_or_routine =~ /\.gif$/i   ? 'newFromGif'
               : $image_or_routine =~ /\.xbm$/i   ? 'newFromXbm'
	       : '';
    return unless $method;
    my $image = eval {$self->image_package->$method($image_or_routine)};
    unless ($image) {
      warn $@;
      return;

t/BioGraphics.t  view on Meta::CPAN


sub do_compare {
  my $test = shift;
  my $cangif = GD::Image->can('gif');
  my @input_files = glob($images . ($cangif ? "/$test/*.gif" : "/$test/*.png"));
  my $test_sub    = $test;
  my $panel       = eval "$test_sub()" or die "Couldn't run test";
  my $ok = 0;
  my $test_data = $cangif ? $panel->gd->gif : $panel->gd->png;
  foreach (@input_files) {
      my $gd = $cangif ? GD::Image->newFromGif($_) : GD::Image->newFromPng($_);
      my $reference_data = $cangif ? $gd->gif : $gd->png;
      if ($reference_data eq $test_data) {
	  $ok++;
	  last;
      }
  }
  ok($ok);
}

sub read_file {



( run in 0.614 second using v1.01-cache-2.11-cpan-a1d94b6210f )