#include "imager.h"
+#include "imrender.h"
#include <sys/types.h>
#include <sys/stat.h>
if ( smooth ) {
+ i_render r;
+ i_render_init(&r, im, bit->cols);
for(y=0;y<bit->rows;y++) {
+#if 0
for(x=0;x<bit->width;x++) {
- c = (unsigned char)bmap[y*(bit->cols)+x];
- i=255-c;
- i_gpix(im,x+xb,y+yb,&val);
- for(ch=0;ch<im->channels;ch++)
- val.channel[ch] = (c*cl->channel[ch]+i*val.channel[ch])/255;
- i_ppix(im,x+xb,y+yb,&val);
+ c = (unsigned char)bmap[y*(bit->cols)+x];
+ i=255-c;
+ i_gpix(im,x+xb,y+yb,&val);
+ for(ch=0;ch<im->channels;ch++)
+ val.channel[ch] = (c*cl->channel[ch]+i*val.channel[ch])/255;
+ i_ppix(im,x+xb,y+yb,&val);
}
+#else
+ i_render_color(&r, xb, yb+y, bit->cols, bmap + y*bit->cols, cl);
+#endif
}
-
+ i_render_done(&r);
} else {
for(y=0;y<bit->rows;y++) {
unsigned mask = 0x80;
#!perl -w
use strict;
-use Test::More tests => 87;
+use Test::More tests => 91;
$|=1;
BEGIN { use_ok(Imager => ':all') }
require "t/testtools.pl";
-use Imager::Test qw(diff_text_with_nul);
+use Imager::Test qw(diff_text_with_nul is_color3);
init_log("testout/t35ttfont.log",2);
SKIP:
{
- skip("freetype 1.x unavailable or disabled", 86)
+ skip("freetype 1.x unavailable or disabled", 90)
unless i_has_format("tt");
print "# has tt\n";
if (!ok(-f $fontname, "check test font file exists")) {
print "# cannot find fontfile for truetype test $fontname\n";
- skip('Cannot load test font', 85);
+ skip('Cannot load test font', 89);
}
i_init_fonts();
{ # introduced in 0.46 - outputting just space crashes
my $im = Imager->new(xsize=>100, ysize=>100);
my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', size=>14);
- ok($im->string(font=>$font, x=> 5, y => 50, string=>' '),
+ ok($im->string(font=>$font, x=> 5, 'y' => 50, string=>' '),
"outputting just a space was crashing");
}
font => $font, channel => 1, utf8 => 1);
}
+ { # RT 11972
+ # when rendering to a transparent image the coverage should be
+ # expressed in terms of the alpha channel rather than the color
+ my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'tt');
+ my $im = Imager->new(xsize => 40, ysize => 20, channels => 4);
+ ok($im->string(string => "AB", size => 20, aa => 1, color => '#F00',
+ x => 0, y => 15, font => $font),
+ "draw to transparent image");
+ #$im->write(file => "foo.png");
+ my $im_noalpha = $im->convert(preset => 'noalpha');
+ my $im_pal = $im->to_paletted(make_colors => 'mediancut');
+ my @colors = $im_pal->getcolors;
+ is(@colors, 2, "should be only 2 colors");
+ @colors = sort { ($a->rgba)[0] <=> ($b->rgba)[0] } @colors;
+ is_color3($colors[0], 0, 0, 0, "check we got black");
+ is_color3($colors[1], 255, 0, 0, "and red");
+ }
+
ok(1, "end of code");
}