1
0
mirror of synced 2026-01-13 15:27:55 +00:00

added image position and size arguments to pdf_write_g4_fax_image.

This commit is contained in:
Eric Smith 2003-02-21 09:01:33 +00:00
parent 41c6251e6d
commit e459aa5007
5 changed files with 49 additions and 19 deletions

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.3 2003/02/20 04:44:17 eric Exp $
* $Id: bitblt_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@ -39,6 +39,8 @@
struct pdf_g4_image
{
double width, height;
double x, y;
unsigned long Columns;
unsigned long Rows;
int BlackIs1;
@ -69,18 +71,16 @@ void pdf_write_g4_content_callback (pdf_file_handle pdf_file,
struct pdf_obj *stream,
void *app_data)
{
unsigned long width = (8.5 * 72); /* full width of page */
unsigned long height = (11 * 72); /* full height of page */
unsigned long x = 0; /* 0 is left edge */
unsigned long y = 0; /* 0 is bottom edge */
struct pdf_g4_image *image = app_data;
char str1 [100];
char *str2 = "/";
char *str3 = " Do\r\n";
char *str3 = " Do Q\r\n";
/* width 0 0 height x y cm */
sprintf (str1, "q %ld 0 0 %ld %ld %ld cm\r\n", width, height, x, y);
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));
@ -108,7 +108,7 @@ void pdf_write_g4_fax_image_callback (pdf_file_handle pdf_file,
while (row < image->Rows)
{
pdf_stream_write_data (pdf_file, stream, raw,
pdf_stream_write_data (pdf_file, stream, (uint8_t *) raw,
image->bitmap->row_words * sizeof (word_type));
row++;
@ -122,6 +122,10 @@ void pdf_write_g4_fax_image_callback (pdf_file_handle pdf_file,
void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1) /* boolean, typ. false */
@ -136,6 +140,11 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
image = pdf_calloc (sizeof (struct pdf_g4_image));
image->width = width;
image->height = height;
image->x = x;
image->y = y;
image->bitmap = bitmap;
image->Columns = bitmap->rect.max.x - bitmap->rect.min.x;
image->Rows = bitmap->rect.max.y - bitmap->rect.min.y;

6
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.2 2003/02/20 04:44:17 eric Exp $
* $Id: pdf.h,v 1.3 2003/02/21 01:01:33 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@ -54,6 +54,10 @@ void pdf_close_page (pdf_page_handle pdf_page);
Note that rowbytes must be at least (Columns+7)/8, but may be arbitrarily
large. */
void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1); /* boolean, typ. false */

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.3 2003/02/20 04:44:17 eric Exp $
* $Id: pdf_g4.c,v 1.4 2003/02/21 01:01:33 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@ -39,6 +39,8 @@
struct pdf_g4_image
{
double width, height;
double x, y;
unsigned long Columns;
unsigned long Rows;
int BlackIs1;
@ -69,18 +71,16 @@ void pdf_write_g4_content_callback (pdf_file_handle pdf_file,
struct pdf_obj *stream,
void *app_data)
{
unsigned long width = (8.5 * 72); /* full width of page */
unsigned long height = (11 * 72); /* full height of page */
unsigned long x = 0; /* 0 is left edge */
unsigned long y = 0; /* 0 is bottom edge */
struct pdf_g4_image *image = app_data;
char str1 [100];
char *str2 = "/";
char *str3 = " Do\r\n";
char *str3 = " Do Q\r\n";
/* width 0 0 height x y cm */
sprintf (str1, "q %ld 0 0 %ld %ld %ld cm\r\n", width, height, x, y);
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));
@ -108,7 +108,7 @@ void pdf_write_g4_fax_image_callback (pdf_file_handle pdf_file,
while (row < image->Rows)
{
pdf_stream_write_data (pdf_file, stream, raw,
pdf_stream_write_data (pdf_file, stream, (uint8_t *) raw,
image->bitmap->row_words * sizeof (word_type));
row++;
@ -122,6 +122,10 @@ void pdf_write_g4_fax_image_callback (pdf_file_handle pdf_file,
void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
double x,
double y,
double width,
double height,
Bitmap *bitmap,
int ImageMask,
int BlackIs1) /* boolean, typ. false */
@ -136,6 +140,11 @@ void pdf_write_g4_fax_image (pdf_page_handle pdf_page,
image = pdf_calloc (sizeof (struct pdf_g4_image));
image->width = width;
image->height = height;
image->x = x;
image->y = y;
image->bitmap = bitmap;
image->Columns = bitmap->rect.max.x - bitmap->rect.min.x;
image->Rows = bitmap->rect.max.y - bitmap->rect.min.y;

6
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.22 2003/02/20 04:44:17 eric Exp $
* $Id: t2p.c,v 1.23 2003/02/21 01:01:33 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@ -465,6 +465,10 @@ 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,
bitmap,
0, /* ImageMask */
0); /* BlackIs1 */

View File

@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* Main program
* $Id: tumble.c,v 1.22 2003/02/20 04:44:17 eric Exp $
* $Id: tumble.c,v 1.23 2003/02/21 01:01:33 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@ -465,6 +465,10 @@ 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,
bitmap,
0, /* ImageMask */
0); /* BlackIs1 */