Hi Again, To get the ball rolling, attached is proposed patch to src/base/pdf-stm-f-pred.c.
The crux of this patch is that encoded PNG predictor tags should be in the range 0..4, as specified in section 6 of RFC 2083 Portable Network Graphics Specification, not 10..14. There's also a couple of minor secondary fixes to (a) keep PNG, TIFF and NONE modes distinct and (b) ensure also PNG prediction arithmetic is unsigned (pdf_uchar_t, rather than pdf_char_t).. I haven't worked out how to drive the test sub-system yet, but the following program demonstrates some of the expected differences: include <stdio.h> #include <string.h> #include <stdlib.h> #include "pdf.h" void main() { pdf_error_t *error = NULL; pdf_char_t* buf = "\100\101\102" "\120\120\120"; pdf_size_t buflen = strlen(buf); pdf_stm_t* stm = pdf_stm_mem_new(buf, buflen, 0, PDF_STM_READ, &error); pdf_hash_t* hash = pdf_hash_new(&error); pdf_hash_add_size(hash, "Predictor", 11, &error); pdf_hash_add_size(hash, "BitsPerComponent", 8, &error); pdf_hash_add_size(hash, "Colors", 3, &error); pdf_hash_add_size(hash, "Columns", 1, &error); pdf_stm_install_filter(stm, PDF_STM_FILTER_PRED_ENC, hash, &error); pdf_char_t outbuf[100]; pdf_size_t read_bytes; pdf_stm_read(stm, outbuf, sizeof(outbuf), &read_bytes, &error); fprintf(stdout, "read bytes: %ld", read_bytes); /* dump the output buffer */ for (int i = 0; i < read_bytes; i++) { char* fmt = i%4 ? " %d" : "\n[%d]"; fprintf(stdout, fmt, (int) outbuf[i]); } fprintf(stdout, "\n"); if (error) { fprintf(stderr, "error: %s", pdf_error_get_message(error)); exit(1); } exit(0); } This program is encoding with the PNG 'sub' filter (/Predictor 11). Before applying the patch it produces [11] 64 1 1 [11] 80 0 0 After applying this patch: [1] 64 1 1 [1] 80 0 0 I'm hoping that someone on the mailing list has time to dust-off gnupdf and look at the attached patch. Feedback welcome. Regards, David On Tue, Mar 29, 2016 at 3:46 PM, David Warring <david.warr...@gmail.com> wrote: > Hi All, > As a newcomer to gnupdf, I've gone to the trouble of downloading the > project from the bazaar repo at http://bzr.savannah.gnu.org/r/pdf and > building and installing (still works). > > At this stage, I'm most interested in filters and streams. I'm looking for > a suitable stream/filter/encryption backend for Perl 6 module which is > under development (https://github.com/p6-pdf/perl6-PDF-Tools). > > I realize that this project has been inactive for some-time, but it > seems to me that the low level stuff that I'm interested in, such as > filters is working or close working, but may need some bug fixes and > general support to get it across the line. > > Is anyone interested in picking up bug fixing and general support for > gnupdf? > > Regards, > David Warring >
gnupdf-predictor-patch-dw.bzr
Description: Binary data