1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Description: TIFF bilevel fixes
Origin: upstream
Bug-Debian: https://bugs.debian.org/985887
Author: Phil Perry
Reviewed-by: Jeffrey Ratcliffe <jffry@posteo.net>
gregor herrmann <gregoa@debian.org>
Last-Update: 2021-03-28
Applied-Upstream: https://github.com/PhilterPaper/Perl-PDF-Builder/commit/d03b59847ecfbf3c7c31b8c1901d3878dba08040
--- a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
+++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm
@@ -164,6 +164,9 @@
$dict->{'BitsPerComponent'} = PDFNum($tif->{'bitsPerSample'});
$dict->{'Colors'} = PDFNum($tif->{'colorSpace'} eq 'DeviceGray'?1 :3);
+ if (!defined $tif->{'filter'} && $tif->{'bitsPerSample'} == 1) {
+ $self->{'Decode'} = PDFArray(PDFNum(1), PDFNum(0));
+ }
$stripcount = $tif->{'object'}->NumberOfStrips();
$buffer = '';
for my $i (0 .. $stripcount - 1) {
@@ -586,9 +589,10 @@
$decode->{'K'} = (($tif->{'ccitt'} == 4 || (defined $tif->{'g3Options'} && $tif->{'g3Options'} & 0x1))? PDFNum(-1): PDFNum(0));
$decode->{'Columns'} = PDFNum($tif->{'imageWidth'});
$decode->{'Rows'} = PDFNum($tif->{'imageHeight'});
- # not sure why whiteIsZero needs to be flipped around???
- $decode->{'BlackIs1'} = PDFBool($tif->{'whiteIsZero'} == 0? 1: 0);
+ $decode->{'BlackIs1'} = PDFBool($tif->{'whiteIsZero'} == 1? 1: 0);
$decode->{'DamagedRowsBeforeError'} = PDFNum(100);
+ # all CCITT Fax need to flip black/white
+ $self->{'Decode'} = PDFArray(PDFNum(1), PDFNum(0));
# g3Options bit 0 = 0 for 1-Dimensional, = 1 for 2-Dimensional MR
# aka T4Options bit 1 = 0 (compressed data only)
@@ -640,12 +644,6 @@
sub read_tiff {
my ($self, $pdf, $tif, %opts) = @_;
- # not sure why blackIsZero needs to be flipped around???
- if (defined $tif->{'blackIsZero'}) {
- $tif->{'blackIsZero'} = $tif->{'blackIsZero'} == 1? 0: 1;
- $tif->{'whiteIsZero'} = $tif->{'blackIsZero'} == 1? 0: 1;
- }
-
$self->width($tif->{'imageWidth'});
$self->height($tif->{'imageHeight'});
|