Imager

 view release on metacpan or  search on metacpan

FT2/t/t10ft2.t  view on Meta::CPAN

  ok($Imager::formats{ft2}, "ft2 should be in %formats");

  my $fontname=$ENV{'TTFONTTEST'} || $deffont;

  -f $fontname or skip("cannot find fontfile $fontname", 189);

  print STDERR "FreeType2 runtime ", Imager::Font::FT2::i_ft2_version(1), 
    " compile-time ", Imager::Font::FT2::i_ft2_version(0), "\n";

  my $bgcolor=i_color_new(255,0,0,0);
  my $overlay=Imager::ImgRaw::new(200,70,3);
  
  my $ttraw=Imager::Font::FT2::i_ft2_new($fontname, 0);
  
  $ttraw or print Imager::_error_as_msg(),"\n";
  ok($ttraw, "loaded raw font");

  my @bbox=Imager::Font::FT2::i_ft2_bbox($ttraw, 50.0, 0, 'XMCLH', 0);
  print "#bbox @bbox\n";
  
  is(@bbox, 8, "i_ft2_bbox() returns 8 values");

  ok(Imager::Font::FT2::i_ft2_cp($ttraw,$overlay,5,50,1,50.0,50, 'XMCLH',1,1, 0, 0), "drawn to channel");
  i_line($overlay,0,50,100,50,$bgcolor,1);

  push @test_output, "t38ft2font.ppm";
  open(FH,">testout/t38ft2font.ppm") || die "cannot open testout/t38ft2font.ppm\n";
  binmode(FH);
  my $IO = Imager::io_new_fd(fileno(FH));
  ok(i_writeppm_wiol($overlay, $IO), "saved image");
  close(FH);

  $bgcolor=i_color_set($bgcolor,200,200,200,0);
  my $backgr=Imager::ImgRaw::new(500,300,3);
  
  #     i_tt_set_aa(2);
  ok(Imager::Font::FT2::i_ft2_text($ttraw,$backgr,100,150,NC(255, 64, 64),200.0,50, 'MAW',1,1,0, 0), "drew MAW");
  Imager::Font::FT2::i_ft2_settransform($ttraw, [0.9659, 0.2588, 0, -0.2588, 0.9659, 0 ]);
  ok(Imager::Font::FT2::i_ft2_text($ttraw,$backgr,100,150,NC(0, 128, 0),200.0,50, 'MAW',0,1, 0, 0), "drew rotated MAW");
  i_line($backgr, 0,150, 499, 150, NC(0, 0, 255),1);

GIF/t/t10gif.t  view on Meta::CPAN

  my $expected = Imager->new;
  ok($expected->read(file=>'testimg/expected.gif'),
     "read expected via OO");
  is(i_img_diff($im->{IMG}, $expected->{IMG}), 0,
     "compare them");
  
  # check the default read doesn't match
  ok($im->read(file=>'testimg/screen2.gif'),
     "read same image without consolidate");
  isnt(i_img_diff($im->{IMG}, $expected->{IMG}), 0,
       "compare them - shouldn't include the overlayed second image");
}
{
  print "# test the reading of single pages\n";
  # build a test file
  my $test_file = 'testout/t105_multi_sing.gif';
  my $im1 = Imager->new(xsize=>100, ysize=>100);
  $im1->box(filled=>1, color=>$blue);
  $im1->addtag(name=>'gif_left', value=>10);
  $im1->addtag(name=>'gif_top', value=>15);
  $im1->addtag(name=>'gif_comment', value=>'First page');

T1/t/t10type1.t  view on Meta::CPAN

  ok(-e("t1lib.log"), "enable t1log");
  init(t1log=>0);
  unlink "t1lib.log";

  my $fnum=Imager::Font::T1xs->new($fontname_pfb,$fontname_afm); # this will load the pfb font
  unless (ok($fnum >= 0, "load font $fontname_pfb")) {
    skip("without the font I can't do a thing", 90);
  }

  my $bgcolor=Imager::Color->new(255,0,0,255);
  my $overlay=Imager::ImgRaw::new(200,70,3);
  
  ok($fnum->cp($overlay,5,50,1,50.0,'XMCLH',1), "i_t1_cp");

  i_line($overlay,0,50,100,50,$bgcolor,1);

  my @bbox=$fnum->bbox(50.0,'XMCLH');
  is(@bbox, 8, "i_t1_bbox");
  print "# bbox: ($bbox[0], $bbox[1]) - ($bbox[2], $bbox[3])\n";

  open(FH,">testout/t30t1font.ppm") || die "cannot open testout/t35t1font.ppm\n";
  binmode(FH); # for os2
  my $IO = Imager::io_new_fd( fileno(FH) );
  i_writeppm_wiol($overlay,$IO);
  close(FH);

  $bgcolor=Imager::Color::set($bgcolor,200,200,200,255);
  my $backgr=Imager::ImgRaw::new(280,300,3);

  ok($fnum->text($backgr,10,100,$bgcolor,150.0,'test',1,2), "i_t1_text");

  # "UTF8" tests
  # for perl < 5.6 we can hand-encode text
  # since T1 doesn't support over 256 chars in an encoding we just drop

W32/t/t10win32.t  view on Meta::CPAN


SKIP:
{
  print "# has w32\n";

  my $fontname=$ENV{'TTFONTTEST'} || 'Times New Roman Bold';
  
  # i_init_fonts(); # unnecessary for Win32 font support

  my $bgcolor=i_color_new(255,0,0,0);
  my $overlay=Imager::ImgRaw::new(200,70,3);
  
  my @bbox=Imager::Font::W32::i_wf_bbox($fontname, 50.0,'XMCLH');
  print "#bbox: ($bbox[0], $bbox[1]) - ($bbox[2], $bbox[3])\n";
  
  ok(Imager::Font::W32::i_wf_cp($fontname,$overlay,5,50,1,50.0,'XMCLH',1,1),
     "i_wf_cp smoke test");
  i_line($overlay,0,50,100,50,$bgcolor, 1);
  
  if (open(FH,">testout/t10font.ppm")) {
    binmode(FH);
    my $io = Imager::io_new_fd(fileno(FH));
    i_writeppm_wiol($overlay,$io);
    close(FH);
  }
  else {
    diag "cannot open testout/t10font.ppm: $!";
  }
  
  $bgcolor=i_color_set($bgcolor,200,200,200,255);
  my $backgr=Imager::ImgRaw::new(500,300,3);
  
  ok(Imager::Font::W32::i_wf_text($fontname,$backgr,100,100,$bgcolor,100,'MAW.',1, 1),

lib/Imager/APIRef.pod  view on Meta::CPAN

 info[3] - channel mask


=for comment
From: File image.c

=item i_rubthru(C<im>, C<src>, C<tx>, C<ty>, C<src_minx>, C<src_miny>, C<src_maxx>, C<src_maxy>)


Takes the sub image C<src>[C<src_minx>, C<src_maxx>)[C<src_miny>, C<src_maxy>)> and
overlays it at (C<tx>,C<ty>) on the image object.

The alpha channel of each pixel in C<src> is used to control how much
the existing color in C<im> is replaced, if it is 255 then the color
is completely replaced, if it is 0 then the original color is left
unmodified.


=for comment
From: File rubthru.im

lib/Imager/Files.pod  view on Meta::CPAN

=back

You can supply a C<page> parameter to the C<read()> method to read
some page other than the first.  The page is 0 based:

  # read the second image in the file
  $image->read(file=>"example.gif", page=>1)
    or die "Cannot read second page: ",$image->errstr,"\n";

Before release 0.46, Imager would read multiple image GIF image files
into a single image, overlaying each of the images onto the virtual
GIF screen.

As of 0.46 the default is to read the first image from the file, as if
called with C<< page => 0 >>.

You can return to the previous behavior by calling read with the
C<gif_consolidate> parameter set to a true value:

  $img->read(file=>$some_gif_file, gif_consolidate=>1);

lib/Imager/Fill.pm  view on Meta::CPAN

=item *

C<tile_L> - L-shaped tiles

=back

=item *

C<fg>, C<bg> - The C<fg> color is rendered where bits are set in the
hatch, and the C<bg> where they are clear.  If you use a transparent
C<fg> or C<bg>, and set combine, you can overlay the hatch onto an
existing image.

C<fg> defaults to black, C<bg> to white.

=item *

C<dx>, C<dy> - An offset into the hatch cell.  Both default to zero.

=back

lib/Imager/Transformations.pod  view on Meta::CPAN


If the source image is color and the target is gray scale, the
source is treated as if run through C<< convert(preset=>'gray') >>.

=item rubthrough()

A more complicated way of blending images is where one image is
put 'over' the other with a certain amount of opaqueness.  The
method that does this is rubthrough().

  $img->rubthrough(src=>$overlay,
                   tx=>30,       ty=>50,
                   src_minx=>20, src_miny=>30,
                   src_maxx=>20, src_maxy=>30);

That will take the sub image defined by I<$overlay> and
I<[src_minx,src_maxx)[src_miny,src_maxy)> and overlay it on top of
I<$img> with the upper left corner at (30,50).  You can rub 2 or 4
channel images onto a 3 channel image, or a 2 channel image onto a 1
channel image.  The last channel is used as an alpha channel.  To add
an alpha channel to an image see I<convert()>.

Parameters:

=over

=item *

t/350-font/020-tt.t  view on Meta::CPAN


  if (!ok(-f $fontname, "check test font file exists")) {
    print "# cannot find fontfile for truetype test $fontname\n";
    skip('Cannot load test font', 89);
  }

  #i_init_fonts();
  #     i_tt_set_aa(1);
  
  my $bgcolor = i_color_new(255,0,0,0);
  my $overlay = Imager::ImgRaw::new(320,140,3);
  i_box_filled($overlay, 0, 0, 319, 139, i_color_new(128, 128, 128));
  
  my $ttraw = Imager::i_tt_new($fontname);
  ok($ttraw, "create font");

  my @bbox = i_tt_bbox($ttraw,50.0,'XMCLH',0);
  is(@bbox, 8, "bounding box");
  print "#bbox: ($bbox[0], $bbox[1]) - ($bbox[2], $bbox[3])\n";

  ok(i_tt_cp($ttraw,$overlay,5,50,1,50.0,'XM CLH',6,1,0), "cp output");
  ok(i_tt_cp($ttraw,$overlay,5,120,1,50.0,'XM CLH',6,0,0), "cp output (non AA)");
  i_line($overlay,0,50,100,50,$bgcolor,1);

  open(FH,">testout/t35ttfont.ppm") || die "cannot open testout/t35ttfont.ppm\n";
  binmode(FH);
  my $IO = Imager::io_new_fd( fileno(FH) );
  ok(i_writeppm_wiol($overlay, $IO), "save t35ttfont.ppm");
  close(FH);

  $bgcolor=i_color_set($bgcolor,200,200,200,0);
  my $backgr=Imager::ImgRaw::new(500,300,3);
  
  #     i_tt_set_aa(2);
  
  ok(i_tt_text($ttraw,$backgr,100,120,$bgcolor,50.0,'te st',5,1,0),
      "normal output");
  ok(i_tt_text($ttraw,$backgr,100,200,$bgcolor,50.0,'te st',5,0,0),

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.550 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )