1
0
mirror of synced 2026-03-03 10:23:20 +00:00

implemented ImageMask fill color arguments to pdf_write_g4_fax_image().

This commit is contained in:
Eric Smith
2003-02-21 09:25:47 +00:00
parent c52d3b4df2
commit c23fe6facd
8 changed files with 81 additions and 54 deletions

4
TODO
View File

@@ -1,5 +1,5 @@
t2p TODO list
$Id: TODO,v 1.8 2003/02/21 01:12:05 eric Exp $
$Id: TODO,v 1.9 2003/02/21 01:25:47 eric Exp $
No particular order.
@@ -78,8 +78,6 @@ Adobe Systems Incorporated, Addison-Wesley, 1993.]
* balance pages tree - currently a degenerate single-level tree, but the
PDF spec recommends max. of 6 children per parent
* ImageMask (p. 79) using fill color (g, k, or rg operator, p. 95)
* thumbnails
* PDF Page rotate attribute (p. 53)?

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: bitblt_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $
* $Id: bitblt_g4.c,v 1.5 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -41,9 +41,11 @@ struct pdf_g4_image
{
double width, height;
double x, y;
double r, g, b; /* fill color, only for ImageMask */
unsigned long Columns;
unsigned long Rows;
int BlackIs1;
bool ImageMask;
bool BlackIs1;
Bitmap *bitmap;
char XObject_name [4];
};
@@ -73,20 +75,16 @@ void pdf_write_g4_content_callback (pdf_file_handle pdf_file,
{
struct pdf_g4_image *image = app_data;
char str1 [100];
char *str2 = "/";
char *str3 = " Do Q\r\n";
/* transformation matrix is: width 0 0 height x y cm */
pdf_stream_printf (pdf_file, stream, "q %g 0 0 %g %g %g cm ",
image->width, image->height,
image->x, image->y);
if (image->ImageMask)
pdf_stream_printf (pdf_file, stream, "%g %g %g rg ",
image->r, image->g, image->b);
/* width 0 0 height x y cm */
sprintf (str1, "q %g 0 0 %g %g %g cm\r\n",
image->width, image->height,
image->x, image->y);
pdf_stream_write_data (pdf_file, stream, str1, strlen (str1));
pdf_stream_write_data (pdf_file, stream, str2, strlen (str2));
pdf_stream_write_data (pdf_file, stream, & image->XObject_name [0],
strlen (& image->XObject_name [0]));
pdf_stream_write_data (pdf_file, stream, str3, strlen (str3));
pdf_stream_printf (pdf_file, stream, "/%s Do Q\r\n",
image->XObject_name);
}
@@ -127,8 +125,11 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1) /* boolean, typ. false */
bool ImageMask,
double r, /* RGB fill color, only for ImageMask */
double g,
double b,
bool BlackIs1) /* boolean, typ. false */
{
struct pdf_g4_image *image;
@@ -144,10 +145,14 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
image->height = height;
image->x = x;
image->y = y;
image->r = r;
image->g = g;
image->b = b;
image->bitmap = bitmap;
image->Columns = bitmap->rect.max.x - bitmap->rect.min.x;
image->Rows = bitmap->rect.max.y - bitmap->rect.min.y;
image->ImageMask = ImageMask;
image->BlackIs1 = BlackIs1;
stream_dict = pdf_new_obj (PT_DICTIONARY);

9
pdf.h
View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf.h,v 1.3 2003/02/21 01:01:33 eric Exp $
* $Id: pdf.h,v 1.4 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -59,8 +59,11 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1); /* boolean, typ. false */
bool ImageMask,
double r, /* RGB fill color, only for ImageMask */
double g,
double b,
bool BlackIs1); /* boolean, typ. false */
void pdf_set_page_number (pdf_page_handle pdf_page, char *page_number);

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $
* $Id: pdf_g4.c,v 1.5 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -41,9 +41,11 @@ struct pdf_g4_image
{
double width, height;
double x, y;
double r, g, b; /* fill color, only for ImageMask */
unsigned long Columns;
unsigned long Rows;
int BlackIs1;
bool ImageMask;
bool BlackIs1;
Bitmap *bitmap;
char XObject_name [4];
};
@@ -73,20 +75,16 @@ void pdf_write_g4_content_callback (pdf_file_handle pdf_file,
{
struct pdf_g4_image *image = app_data;
char str1 [100];
char *str2 = "/";
char *str3 = " Do Q\r\n";
/* transformation matrix is: width 0 0 height x y cm */
pdf_stream_printf (pdf_file, stream, "q %g 0 0 %g %g %g cm ",
image->width, image->height,
image->x, image->y);
if (image->ImageMask)
pdf_stream_printf (pdf_file, stream, "%g %g %g rg ",
image->r, image->g, image->b);
/* width 0 0 height x y cm */
sprintf (str1, "q %g 0 0 %g %g %g cm\r\n",
image->width, image->height,
image->x, image->y);
pdf_stream_write_data (pdf_file, stream, str1, strlen (str1));
pdf_stream_write_data (pdf_file, stream, str2, strlen (str2));
pdf_stream_write_data (pdf_file, stream, & image->XObject_name [0],
strlen (& image->XObject_name [0]));
pdf_stream_write_data (pdf_file, stream, str3, strlen (str3));
pdf_stream_printf (pdf_file, stream, "/%s Do Q\r\n",
image->XObject_name);
}
@@ -127,8 +125,11 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1) /* boolean, typ. false */
bool ImageMask,
double r, /* RGB fill color, only for ImageMask */
double g,
double b,
bool BlackIs1) /* boolean, typ. false */
{
struct pdf_g4_image *image;
@@ -144,10 +145,14 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
image->height = height;
image->x = x;
image->y = y;
image->r = r;
image->g = g;
image->b = b;
image->bitmap = bitmap;
image->Columns = bitmap->rect.max.x - bitmap->rect.min.x;
image->Rows = bitmap->rect.max.y - bitmap->rect.min.y;
image->ImageMask = ImageMask;
image->BlackIs1 = BlackIs1;
stream_dict = pdf_new_obj (PT_DICTIONARY);

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf_prim.c,v 1.3 2003/02/20 04:44:17 eric Exp $
* $Id: pdf_prim.c,v 1.4 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
*/
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -452,6 +453,18 @@ void pdf_stream_write_data (pdf_file_handle pdf_file,
}
void pdf_stream_printf (pdf_file_handle pdf_file,
struct pdf_obj *stream,
char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
vfprintf (pdf_file->f, fmt, ap);
va_end (ap);
}
void pdf_write_stream (pdf_file_handle pdf_file, struct pdf_obj *stream)
{
unsigned long begin_pos, end_pos;

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf_prim.h,v 1.2 2003/02/20 04:44:17 eric Exp $
* $Id: pdf_prim.h,v 1.3 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -95,13 +95,18 @@ struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,
pdf_stream_write_callback callback,
void *app_data);
/* The callback should call pdf_stream_write_data to write the actual
stream data. */
/* The callback should call pdf_stream_write_data or pdf_stream_printf
to write the actual stream data. */
void pdf_stream_write_data (pdf_file_handle pdf_file,
struct pdf_obj *stream,
char *data,
unsigned long len);
void pdf_stream_printf (pdf_file_handle pdf_file,
struct pdf_obj *stream,
char *fmt, ...);
void pdf_stream_add_filter (struct pdf_obj *stream,
char *filter_name,
struct pdf_obj *decode_parms);

9
t2p.c
View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* Main program
* $Id: t2p.c,v 1.23 2003/02/21 01:01:33 eric Exp $
* $Id: t2p.c,v 1.24 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -465,12 +465,11 @@ bool process_page (int image, /* range 1 .. n */
page = pdf_new_page (out->pdf, width_points, height_points);
pdf_write_g4_fax_image (page,
0, /* x */
0, /* y */
width_points,
height_points,
0, 0, /* x, y */
width_points, height_points,
bitmap,
0, /* ImageMask */
0, 0, 0, /* r, g, b */
0); /* BlackIs1 */
free_bitmap (bitmap);

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* Main program
* $Id: tumble.c,v 1.23 2003/02/21 01:01:33 eric Exp $
* $Id: tumble.c,v 1.24 2003/02/21 01:25:47 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -465,12 +465,11 @@ bool process_page (int image, /* range 1 .. n */
page = pdf_new_page (out->pdf, width_points, height_points);
pdf_write_g4_fax_image (page,
0, /* x */
0, /* y */
width_points,
height_points,
0, 0, /* x, y */
width_points, height_points,
bitmap,
0, /* ImageMask */
0, 0, 0, /* r, g, b */
0); /* BlackIs1 */
free_bitmap (bitmap);