From dccd163653afb31824231c4542078892f2e23c7b Mon Sep 17 00:00:00 2001 From: Eric Smith Date: Thu, 20 Mar 2003 07:53:09 +0000 Subject: [PATCH] added color, width_samples, height_samples areguments to pdf_write_jpeg_image(). --- pdf.h | 8 ++++++-- pdf_jpeg.c | 12 +++++++----- tumble_jpeg.c | 15 ++++++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/pdf.h b/pdf.h index ed4c164..f66d06e 100644 --- a/pdf.h +++ b/pdf.h @@ -2,7 +2,7 @@ * tumble: build a PDF file from image files * * PDF routines - * $Id: pdf.h,v 1.12 2003/03/19 22:54:07 eric Exp $ + * $Id: pdf.h,v 1.13 2003/03/19 23:53:09 eric Exp $ * Copyright 2001, 2002, 2003 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -22,7 +22,8 @@ */ -#define POINTS_PER_INCH 72 +/* Acrobat default units aren't really points, but they're close. */ +#define POINTS_PER_INCH 72.0 /* page size limited by Acrobat Reader to 45 inches on a side */ #define PAGE_MAX_INCHES 45 @@ -86,6 +87,9 @@ void pdf_write_jpeg_image (pdf_page_handle pdf_page, double y, double width, double height, + bool color, + uint32_t width_samples, + uint32_t height_samples, FILE *f); diff --git a/pdf_jpeg.c b/pdf_jpeg.c index bf51f56..0978840 100644 --- a/pdf_jpeg.c +++ b/pdf_jpeg.c @@ -2,7 +2,7 @@ * tumble: build a PDF file from image files * * PDF routines - * $Id: pdf_jpeg.c,v 1.4 2003/03/19 23:44:53 eric Exp $ + * $Id: pdf_jpeg.c,v 1.5 2003/03/19 23:53:09 eric Exp $ * Copyright 2003 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -98,6 +98,9 @@ void pdf_write_jpeg_image (pdf_page_handle pdf_page, double y, double width, double height, + bool color, + uint32_t width_samples, + uint32_t height_samples, FILE *f) { struct pdf_jpeg_image *image; @@ -116,10 +119,9 @@ void pdf_write_jpeg_image (pdf_page_handle pdf_page, image->f = f; - /* $$$ quick hack, should read these from file! */ - image->color = 1; - image->width_samples = 71; - image->height_samples = 88; + image->color = color; + image->width_samples = width_samples; + image->height_samples = height_samples; pdf_add_array_elem_unique (pdf_page->procset, pdf_new_name (image->color ? "ImageC" : "ImageB")); diff --git a/tumble_jpeg.c b/tumble_jpeg.c index 9ecbb8d..8ff4f97 100644 --- a/tumble_jpeg.c +++ b/tumble_jpeg.c @@ -1,7 +1,7 @@ /* * tumble: build a PDF file from image files * - * $Id: tumble_jpeg.c,v 1.1 2003/03/19 22:54:08 eric Exp $ + * $Id: tumble_jpeg.c,v 1.2 2003/03/19 23:53:09 eric Exp $ * Copyright 2003 Eric Smith * * This program is free software; you can redistribute it and/or modify @@ -87,6 +87,16 @@ bool get_jpeg_image_info (int image, { double unit; +#ifdef DEBUG_JPEG + printf ("color space: %d\n", cinfo.jpeg_color_space); + printf ("components: %d\n", cinfo.num_components); + printf ("density unit: %d\n", cinfo.density_unit); + printf ("x density: %d\n", cinfo.X_density); + printf ("y density: %d\n", cinfo.Y_density); + printf ("width: %d\n", cinfo.image_width); + printf ("height: %d\n", cinfo.image_height); +#endif + switch (cinfo.jpeg_color_space) { case JCS_GRAYSCALE: @@ -154,6 +164,9 @@ bool process_jpeg_image (int image, /* range 1 .. n */ 0, 0, /* x, y */ image_info->width_points, image_info->height_points, + image_info->color, + image_info->width_samples, + image_info->height_samples, jpeg_f); return (page);