From e459aa500757150de8201c7596f16082b0c07c0b Mon Sep 17 00:00:00 2001 From: Eric Smith Date: Fri, 21 Feb 2003 09:01:33 +0000 Subject: [PATCH] added image position and size arguments to pdf_write_g4_fax_image. --- bitblt_g4.c | 25 +++++++++++++++++-------- pdf.h | 6 +++++- pdf_g4.c | 25 +++++++++++++++++-------- t2p.c | 6 +++++- tumble.c | 6 +++++- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/bitblt_g4.c b/bitblt_g4.c index be18ecc..3fbf94b 100644 --- a/bitblt_g4.c +++ b/bitblt_g4.c @@ -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 * * 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; diff --git a/pdf.h b/pdf.h index 68b6611..1b4c98e 100644 --- a/pdf.h +++ b/pdf.h @@ -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 * * 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 */ diff --git a/pdf_g4.c b/pdf_g4.c index 2e7ffde..37cf0a8 100644 --- a/pdf_g4.c +++ b/pdf_g4.c @@ -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 * * 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; diff --git a/t2p.c b/t2p.c index afe29eb..a69b64e 100644 --- a/t2p.c +++ b/t2p.c @@ -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 * * 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 */ diff --git a/tumble.c b/tumble.c index 8c8e820..4869049 100644 --- a/tumble.c +++ b/tumble.c @@ -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 * * 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 */