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 *
lib/Imager/Transformations.pod view on Meta::CPAN
top left corner of the source.
=item *
C<src_minx>, C<src_miny> - the top left corner in the source to transfer to
the target image. Default: (0, 0).
=item *
C<src_maxx>, C<src_maxy> - the bottom right in the source image of the sub
image to overlay. This position is B<non> inclusive. Default: bottom
right corner of the source image.
=back
# overlay all of $source onto $targ
$targ->rubthrough(tx => 20, ty => 25, src => $source);
# overlay the top left corner of $source onto $targ
$targ->rubthrough(tx => 20, ty => 25, src => $source,
src_maxx => 20, src_maxy => 20);
# overlay the bottom right corner of $source onto $targ
$targ->rubthrough(tx => 20, ty => 30, src => $src,
src_minx => $src->getwidth() - 20,
src_miny => $src->getheight() - 20);
rubthrough() returns true on success. On failure check
C<< $target->errstr >> for the reason for failure.
=item compose()
Draws the source image over the target image, with the source alpha
channel modified by the optional mask and the opacity.
$img->compose(src=>$overlay,
tx=>30, ty=>50,
src_minx=>20, src_miny=>30,
src_maxx=>20, src_maxy=>30,
mask => $mask, opacity => 0.5);
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.
Parameters:
=over
=item *
lib/Imager/Transformations.pod view on Meta::CPAN
C<right>. Default: (0, 0).
=item *
C<src_minx>, C<src_miny> - the top left corner in the source to transfer to
the target image. Default: (0, 0).
=item *
C<src_maxx>, C<src_maxy> - the bottom right in the source image of the sub
image to overlay. This position is B<non> inclusive. Default: bottom
right corner of the source image.
=item *
C<mask> - a mask image. The first channel of this image is used to
modify the alpha channel of the source image. This can be used to
mask out portions of the source image. Where the first channel is
zero none of the source image will be used, where the first channel is
maximum the full alpha of the source image will be used, as further
modified by the opacity.
lib/Imager/Transformations.pod view on Meta::CPAN
normal.
=back
Calling compose() with no mask, combine set to C<normal>, opacity set
to C<1.0> is equivalent to calling rubthrough().
compose() is intended to be produce similar effects to layers in
interactive paint software.
# overlay all of $source onto $targ
$targ->compose(tx => 20, ty => 25, src => $source);
# overlay the top left corner of $source onto $targ
$targ->compose(tx => 20, ty => 25, src => $source,
src_maxx => 20, src_maxy => 20);
# overlay the bottom right corner of $source onto $targ
$targ->compose(tx => 20, ty => 30, src => $src,
src_minx => $src->getwidth() - 20,
src_miny => $src->getheight() - 20);
compose() returns true on success. On failure check $target->errstr
for the reason for failure.
=item flip()
An inplace horizontal or vertical flip is possible by calling the
#/code
return 1;
}
/*
=item i_rubthru(C<im>, C<src>, C<tx>, C<ty>, C<src_minx>, C<src_miny>, C<src_maxx>, C<src_maxy>)
=category Image
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.
=cut
*/
int
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),