Skip to content

Commit

Permalink
initialize the index when packing 4 bit data into bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Cook committed Dec 10, 2001
1 parent 07ddf04 commit e60161b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Imager/Changes
Expand Up @@ -560,6 +560,7 @@ Revision history for Perl extension Imager.
- added has_chars() method to Imager::Font::FreeType2
- freetype 2 bounding box function didn't know UTF8 (doh!)
- write paletted images as paletted to tiff
- initialize counter for packing 4 bit data

=================================================================

Expand Down
4 changes: 3 additions & 1 deletion Imager/t/t106tiff.t
Expand Up @@ -189,8 +189,10 @@ if (!i_has_format("tiff")) {
ok($bad->read(file=>'testimg/comp4bad.tif'), "bad image not returned");
ok(scalar $bad->tags(name=>'i_incomplete'), "incomplete tag not set");
ok($img8->write(file=>'testout/t106_pal8.tif'), "writing 8-bit paletted");
ok(my $cmp8 = Imager->new->read(file=>'testout/t106pal8.tif'),
my $cmp8 = Imager->new;
ok($cmp8->read(file=>'testout/t106_pal8.tif'),
"reading 8-bit paletted");
#print "# ",$cmp8->errstr,"\n";
ok($cmp8->type eq 'paletted', "pal8 isn't paletted");
ok($cmp8->colorcount == 256, "pal8 bad colorcount");
$diff = i_img_diff($img8->{IMG}, $cmp8->{IMG});
Expand Down
3 changes: 2 additions & 1 deletion Imager/tiff.c
Expand Up @@ -539,6 +539,7 @@ i_writetiff_wiol(i_img *im, io_glue *ig) {
mm_log((1, "i_writetiff_wiol: TIFFGetField rowsperstrip=%d\n", rowsperstrip));
mm_log((1, "i_writetiff_wiol: TIFFGetField scanlinesize=%d\n", TIFFScanlineSize(tif) ));
mm_log((1, "i_writetiff_wiol: TIFFGetField planarconfig=%d == %d\n", rc, PLANARCONFIG_CONTIG));
mm_log((1, "i_writetiff_wiol: bitspersample = %d\n", bitspersample));

got_xres = i_tags_get_float(&im->tags, "i_xres", 0, &xres);
got_yres = i_tags_get_float(&im->tags, "i_yres", 0, &yres);
Expand Down Expand Up @@ -797,7 +798,7 @@ static void expand_4bit_hl(unsigned char *buf, int count) {
}

static void pack_4bit_hl(unsigned char *buf, int count) {
int i;
int i = 0;
while (i < count) {
buf[i/2] = (buf[i] << 4) + buf[i+1];
i += 2;
Expand Down

0 comments on commit e60161b

Please sign in to comment.