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