Fri, 21 Feb 2003 09:25:47 +0000
implemented ImageMask fill color arguments to pdf_write_g4_fax_image().
TODO | file | annotate | diff | revisions | |
bitblt_g4.c | file | annotate | diff | revisions | |
pdf.h | file | annotate | diff | revisions | |
pdf_g4.c | file | annotate | diff | revisions | |
pdf_prim.c | file | annotate | diff | revisions | |
pdf_prim.h | file | annotate | diff | revisions | |
t2p.c | file | annotate | diff | revisions | |
tumble.c | file | annotate | diff | revisions |
1.1 --- a/TODO Fri Feb 21 09:12:05 2003 +0000 1.2 +++ b/TODO Fri Feb 21 09:25:47 2003 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 t2p TODO list 1.5 -$Id: TODO,v 1.8 2003/02/21 01:12:05 eric Exp $ 1.6 +$Id: TODO,v 1.9 2003/02/21 01:25:47 eric Exp $ 1.7 1.8 No particular order. 1.9 1.10 @@ -78,8 +78,6 @@ 1.11 * balance pages tree - currently a degenerate single-level tree, but the 1.12 PDF spec recommends max. of 6 children per parent 1.13 1.14 -* ImageMask (p. 79) using fill color (g, k, or rg operator, p. 95) 1.15 - 1.16 * thumbnails 1.17 1.18 * PDF Page rotate attribute (p. 53)?
2.1 --- a/bitblt_g4.c Fri Feb 21 09:12:05 2003 +0000 2.2 +++ b/bitblt_g4.c Fri Feb 21 09:25:47 2003 +0000 2.3 @@ -4,7 +4,7 @@ 2.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 2.5 * 2.6 * PDF routines 2.7 - * $Id: bitblt_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $ 2.8 + * $Id: bitblt_g4.c,v 1.5 2003/02/21 01:25:47 eric Exp $ 2.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 2.10 * 2.11 * This program is free software; you can redistribute it and/or modify 2.12 @@ -41,9 +41,11 @@ 2.13 { 2.14 double width, height; 2.15 double x, y; 2.16 + double r, g, b; /* fill color, only for ImageMask */ 2.17 unsigned long Columns; 2.18 unsigned long Rows; 2.19 - int BlackIs1; 2.20 + bool ImageMask; 2.21 + bool BlackIs1; 2.22 Bitmap *bitmap; 2.23 char XObject_name [4]; 2.24 }; 2.25 @@ -73,20 +75,16 @@ 2.26 { 2.27 struct pdf_g4_image *image = app_data; 2.28 2.29 - char str1 [100]; 2.30 - char *str2 = "/"; 2.31 - char *str3 = " Do Q\r\n"; 2.32 + /* transformation matrix is: width 0 0 height x y cm */ 2.33 + pdf_stream_printf (pdf_file, stream, "q %g 0 0 %g %g %g cm ", 2.34 + image->width, image->height, 2.35 + image->x, image->y); 2.36 + if (image->ImageMask) 2.37 + pdf_stream_printf (pdf_file, stream, "%g %g %g rg ", 2.38 + image->r, image->g, image->b); 2.39 2.40 - /* width 0 0 height x y cm */ 2.41 - sprintf (str1, "q %g 0 0 %g %g %g cm\r\n", 2.42 - image->width, image->height, 2.43 - image->x, image->y); 2.44 - 2.45 - pdf_stream_write_data (pdf_file, stream, str1, strlen (str1)); 2.46 - pdf_stream_write_data (pdf_file, stream, str2, strlen (str2)); 2.47 - pdf_stream_write_data (pdf_file, stream, & image->XObject_name [0], 2.48 - strlen (& image->XObject_name [0])); 2.49 - pdf_stream_write_data (pdf_file, stream, str3, strlen (str3)); 2.50 + pdf_stream_printf (pdf_file, stream, "/%s Do Q\r\n", 2.51 + image->XObject_name); 2.52 } 2.53 2.54 2.55 @@ -127,8 +125,11 @@ 2.56 double width, 2.57 double height, 2.58 Bitmap *bitmap, 2.59 - int ImageMask, 2.60 - int BlackIs1) /* boolean, typ. false */ 2.61 + bool ImageMask, 2.62 + double r, /* RGB fill color, only for ImageMask */ 2.63 + double g, 2.64 + double b, 2.65 + bool BlackIs1) /* boolean, typ. false */ 2.66 { 2.67 struct pdf_g4_image *image; 2.68 2.69 @@ -144,10 +145,14 @@ 2.70 image->height = height; 2.71 image->x = x; 2.72 image->y = y; 2.73 + image->r = r; 2.74 + image->g = g; 2.75 + image->b = b; 2.76 2.77 image->bitmap = bitmap; 2.78 image->Columns = bitmap->rect.max.x - bitmap->rect.min.x; 2.79 image->Rows = bitmap->rect.max.y - bitmap->rect.min.y; 2.80 + image->ImageMask = ImageMask; 2.81 image->BlackIs1 = BlackIs1; 2.82 2.83 stream_dict = pdf_new_obj (PT_DICTIONARY);
3.1 --- a/pdf.h Fri Feb 21 09:12:05 2003 +0000 3.2 +++ b/pdf.h Fri Feb 21 09:25:47 2003 +0000 3.3 @@ -4,7 +4,7 @@ 3.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 3.5 * 3.6 * PDF routines 3.7 - * $Id: pdf.h,v 1.3 2003/02/21 01:01:33 eric Exp $ 3.8 + * $Id: pdf.h,v 1.4 2003/02/21 01:25:47 eric Exp $ 3.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 3.10 * 3.11 * This program is free software; you can redistribute it and/or modify 3.12 @@ -59,8 +59,11 @@ 3.13 double width, 3.14 double height, 3.15 Bitmap *bitmap, 3.16 - int ImageMask, 3.17 - int BlackIs1); /* boolean, typ. false */ 3.18 + bool ImageMask, 3.19 + double r, /* RGB fill color, only for ImageMask */ 3.20 + double g, 3.21 + double b, 3.22 + bool BlackIs1); /* boolean, typ. false */ 3.23 3.24 3.25 void pdf_set_page_number (pdf_page_handle pdf_page, char *page_number);
4.1 --- a/pdf_g4.c Fri Feb 21 09:12:05 2003 +0000 4.2 +++ b/pdf_g4.c Fri Feb 21 09:25:47 2003 +0000 4.3 @@ -4,7 +4,7 @@ 4.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 4.5 * 4.6 * PDF routines 4.7 - * $Id: pdf_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $ 4.8 + * $Id: pdf_g4.c,v 1.5 2003/02/21 01:25:47 eric Exp $ 4.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 4.10 * 4.11 * This program is free software; you can redistribute it and/or modify 4.12 @@ -41,9 +41,11 @@ 4.13 { 4.14 double width, height; 4.15 double x, y; 4.16 + double r, g, b; /* fill color, only for ImageMask */ 4.17 unsigned long Columns; 4.18 unsigned long Rows; 4.19 - int BlackIs1; 4.20 + bool ImageMask; 4.21 + bool BlackIs1; 4.22 Bitmap *bitmap; 4.23 char XObject_name [4]; 4.24 }; 4.25 @@ -73,20 +75,16 @@ 4.26 { 4.27 struct pdf_g4_image *image = app_data; 4.28 4.29 - char str1 [100]; 4.30 - char *str2 = "/"; 4.31 - char *str3 = " Do Q\r\n"; 4.32 + /* transformation matrix is: width 0 0 height x y cm */ 4.33 + pdf_stream_printf (pdf_file, stream, "q %g 0 0 %g %g %g cm ", 4.34 + image->width, image->height, 4.35 + image->x, image->y); 4.36 + if (image->ImageMask) 4.37 + pdf_stream_printf (pdf_file, stream, "%g %g %g rg ", 4.38 + image->r, image->g, image->b); 4.39 4.40 - /* width 0 0 height x y cm */ 4.41 - sprintf (str1, "q %g 0 0 %g %g %g cm\r\n", 4.42 - image->width, image->height, 4.43 - image->x, image->y); 4.44 - 4.45 - pdf_stream_write_data (pdf_file, stream, str1, strlen (str1)); 4.46 - pdf_stream_write_data (pdf_file, stream, str2, strlen (str2)); 4.47 - pdf_stream_write_data (pdf_file, stream, & image->XObject_name [0], 4.48 - strlen (& image->XObject_name [0])); 4.49 - pdf_stream_write_data (pdf_file, stream, str3, strlen (str3)); 4.50 + pdf_stream_printf (pdf_file, stream, "/%s Do Q\r\n", 4.51 + image->XObject_name); 4.52 } 4.53 4.54 4.55 @@ -127,8 +125,11 @@ 4.56 double width, 4.57 double height, 4.58 Bitmap *bitmap, 4.59 - int ImageMask, 4.60 - int BlackIs1) /* boolean, typ. false */ 4.61 + bool ImageMask, 4.62 + double r, /* RGB fill color, only for ImageMask */ 4.63 + double g, 4.64 + double b, 4.65 + bool BlackIs1) /* boolean, typ. false */ 4.66 { 4.67 struct pdf_g4_image *image; 4.68 4.69 @@ -144,10 +145,14 @@ 4.70 image->height = height; 4.71 image->x = x; 4.72 image->y = y; 4.73 + image->r = r; 4.74 + image->g = g; 4.75 + image->b = b; 4.76 4.77 image->bitmap = bitmap; 4.78 image->Columns = bitmap->rect.max.x - bitmap->rect.min.x; 4.79 image->Rows = bitmap->rect.max.y - bitmap->rect.min.y; 4.80 + image->ImageMask = ImageMask; 4.81 image->BlackIs1 = BlackIs1; 4.82 4.83 stream_dict = pdf_new_obj (PT_DICTIONARY);
5.1 --- a/pdf_prim.c Fri Feb 21 09:12:05 2003 +0000 5.2 +++ b/pdf_prim.c Fri Feb 21 09:25:47 2003 +0000 5.3 @@ -4,7 +4,7 @@ 5.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 5.5 * 5.6 * PDF routines 5.7 - * $Id: pdf_prim.c,v 1.3 2003/02/20 04:44:17 eric Exp $ 5.8 + * $Id: pdf_prim.c,v 1.4 2003/02/21 01:25:47 eric Exp $ 5.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 5.10 * 5.11 * This program is free software; you can redistribute it and/or modify 5.12 @@ -24,6 +24,7 @@ 5.13 */ 5.14 5.15 5.16 +#include <stdarg.h> 5.17 #include <stdbool.h> 5.18 #include <stdint.h> 5.19 #include <stdio.h> 5.20 @@ -452,6 +453,18 @@ 5.21 } 5.22 5.23 5.24 +void pdf_stream_printf (pdf_file_handle pdf_file, 5.25 + struct pdf_obj *stream, 5.26 + char *fmt, ...) 5.27 +{ 5.28 + va_list ap; 5.29 + 5.30 + va_start (ap, fmt); 5.31 + vfprintf (pdf_file->f, fmt, ap); 5.32 + va_end (ap); 5.33 +} 5.34 + 5.35 + 5.36 void pdf_write_stream (pdf_file_handle pdf_file, struct pdf_obj *stream) 5.37 { 5.38 unsigned long begin_pos, end_pos;
6.1 --- a/pdf_prim.h Fri Feb 21 09:12:05 2003 +0000 6.2 +++ b/pdf_prim.h Fri Feb 21 09:25:47 2003 +0000 6.3 @@ -4,7 +4,7 @@ 6.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 6.5 * 6.6 * PDF routines 6.7 - * $Id: pdf_prim.h,v 1.2 2003/02/20 04:44:17 eric Exp $ 6.8 + * $Id: pdf_prim.h,v 1.3 2003/02/21 01:25:47 eric Exp $ 6.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 6.10 * 6.11 * This program is free software; you can redistribute it and/or modify 6.12 @@ -95,13 +95,18 @@ 6.13 pdf_stream_write_callback callback, 6.14 void *app_data); 6.15 6.16 -/* The callback should call pdf_stream_write_data to write the actual 6.17 - stream data. */ 6.18 +/* The callback should call pdf_stream_write_data or pdf_stream_printf 6.19 + to write the actual stream data. */ 6.20 void pdf_stream_write_data (pdf_file_handle pdf_file, 6.21 struct pdf_obj *stream, 6.22 char *data, 6.23 unsigned long len); 6.24 6.25 +void pdf_stream_printf (pdf_file_handle pdf_file, 6.26 + struct pdf_obj *stream, 6.27 + char *fmt, ...); 6.28 + 6.29 + 6.30 void pdf_stream_add_filter (struct pdf_obj *stream, 6.31 char *filter_name, 6.32 struct pdf_obj *decode_parms);
7.1 --- a/t2p.c Fri Feb 21 09:12:05 2003 +0000 7.2 +++ b/t2p.c Fri Feb 21 09:25:47 2003 +0000 7.3 @@ -4,7 +4,7 @@ 7.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 7.5 * 7.6 * Main program 7.7 - * $Id: t2p.c,v 1.23 2003/02/21 01:01:33 eric Exp $ 7.8 + * $Id: t2p.c,v 1.24 2003/02/21 01:25:47 eric Exp $ 7.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 7.10 * 7.11 * This program is free software; you can redistribute it and/or modify 7.12 @@ -465,12 +465,11 @@ 7.13 page = pdf_new_page (out->pdf, width_points, height_points); 7.14 7.15 pdf_write_g4_fax_image (page, 7.16 - 0, /* x */ 7.17 - 0, /* y */ 7.18 - width_points, 7.19 - height_points, 7.20 + 0, 0, /* x, y */ 7.21 + width_points, height_points, 7.22 bitmap, 7.23 0, /* ImageMask */ 7.24 + 0, 0, 0, /* r, g, b */ 7.25 0); /* BlackIs1 */ 7.26 7.27 free_bitmap (bitmap);
8.1 --- a/tumble.c Fri Feb 21 09:12:05 2003 +0000 8.2 +++ b/tumble.c Fri Feb 21 09:25:47 2003 +0000 8.3 @@ -4,7 +4,7 @@ 8.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 8.5 * 8.6 * Main program 8.7 - * $Id: tumble.c,v 1.23 2003/02/21 01:01:33 eric Exp $ 8.8 + * $Id: tumble.c,v 1.24 2003/02/21 01:25:47 eric Exp $ 8.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 8.10 * 8.11 * This program is free software; you can redistribute it and/or modify 8.12 @@ -465,12 +465,11 @@ 8.13 page = pdf_new_page (out->pdf, width_points, height_points); 8.14 8.15 pdf_write_g4_fax_image (page, 8.16 - 0, /* x */ 8.17 - 0, /* y */ 8.18 - width_points, 8.19 - height_points, 8.20 + 0, 0, /* x, y */ 8.21 + width_points, height_points, 8.22 bitmap, 8.23 0, /* ImageMask */ 8.24 + 0, 0, 0, /* r, g, b */ 8.25 0); /* BlackIs1 */ 8.26 8.27 free_bitmap (bitmap);