1.1 --- a/bitblt_g4.c Fri Feb 21 09:12:05 2003 +0000 1.2 +++ b/bitblt_g4.c Fri Feb 21 09:25:47 2003 +0000 1.3 @@ -4,7 +4,7 @@ 1.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 1.5 * 1.6 * PDF routines 1.7 - * $Id: bitblt_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $ 1.8 + * $Id: bitblt_g4.c,v 1.5 2003/02/21 01:25:47 eric Exp $ 1.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 * 1.11 * This program is free software; you can redistribute it and/or modify 1.12 @@ -41,9 +41,11 @@ 1.13 { 1.14 double width, height; 1.15 double x, y; 1.16 + double r, g, b; /* fill color, only for ImageMask */ 1.17 unsigned long Columns; 1.18 unsigned long Rows; 1.19 - int BlackIs1; 1.20 + bool ImageMask; 1.21 + bool BlackIs1; 1.22 Bitmap *bitmap; 1.23 char XObject_name [4]; 1.24 }; 1.25 @@ -73,20 +75,16 @@ 1.26 { 1.27 struct pdf_g4_image *image = app_data; 1.28 1.29 - char str1 [100]; 1.30 - char *str2 = "/"; 1.31 - char *str3 = " Do Q\r\n"; 1.32 + /* transformation matrix is: width 0 0 height x y cm */ 1.33 + pdf_stream_printf (pdf_file, stream, "q %g 0 0 %g %g %g cm ", 1.34 + image->width, image->height, 1.35 + image->x, image->y); 1.36 + if (image->ImageMask) 1.37 + pdf_stream_printf (pdf_file, stream, "%g %g %g rg ", 1.38 + image->r, image->g, image->b); 1.39 1.40 - /* width 0 0 height x y cm */ 1.41 - sprintf (str1, "q %g 0 0 %g %g %g cm\r\n", 1.42 - image->width, image->height, 1.43 - image->x, image->y); 1.44 - 1.45 - pdf_stream_write_data (pdf_file, stream, str1, strlen (str1)); 1.46 - pdf_stream_write_data (pdf_file, stream, str2, strlen (str2)); 1.47 - pdf_stream_write_data (pdf_file, stream, & image->XObject_name [0], 1.48 - strlen (& image->XObject_name [0])); 1.49 - pdf_stream_write_data (pdf_file, stream, str3, strlen (str3)); 1.50 + pdf_stream_printf (pdf_file, stream, "/%s Do Q\r\n", 1.51 + image->XObject_name); 1.52 } 1.53 1.54 1.55 @@ -127,8 +125,11 @@ 1.56 double width, 1.57 double height, 1.58 Bitmap *bitmap, 1.59 - int ImageMask, 1.60 - int BlackIs1) /* boolean, typ. false */ 1.61 + bool ImageMask, 1.62 + double r, /* RGB fill color, only for ImageMask */ 1.63 + double g, 1.64 + double b, 1.65 + bool BlackIs1) /* boolean, typ. false */ 1.66 { 1.67 struct pdf_g4_image *image; 1.68 1.69 @@ -144,10 +145,14 @@ 1.70 image->height = height; 1.71 image->x = x; 1.72 image->y = y; 1.73 + image->r = r; 1.74 + image->g = g; 1.75 + image->b = b; 1.76 1.77 image->bitmap = bitmap; 1.78 image->Columns = bitmap->rect.max.x - bitmap->rect.min.x; 1.79 image->Rows = bitmap->rect.max.y - bitmap->rect.min.y; 1.80 + image->ImageMask = ImageMask; 1.81 image->BlackIs1 = BlackIs1; 1.82 1.83 stream_dict = pdf_new_obj (PT_DICTIONARY);