From 1083fdcdb608210a42e00fc6819a6d5ce5996b2a Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Fri, 3 Oct 2014 14:05:35 +0000 Subject: Imported Upstream version 0.994 --- src/xsane-device-preferences.c | 14 ++ src/xsane-multipage-project.c | 4 +- src/xsane-preferences.c | 2 +- src/xsane-preferences.h | 2 +- src/xsane-save.c | 306 +++++++++++++++++++++++------------------ src/xsane-save.h | 15 +- src/xsane-scan.c | 42 +++++- src/xsane-setup.c | 15 ++ src/xsane-text.h | 2 + src/xsane.h | 3 +- 10 files changed, 255 insertions(+), 150 deletions(-) (limited to 'src') diff --git a/src/xsane-device-preferences.c b/src/xsane-device-preferences.c index 41293e6..ce05cae 100644 --- a/src/xsane-device-preferences.c +++ b/src/xsane-device-preferences.c @@ -440,7 +440,10 @@ void xsane_device_preferences_load_file(char *filename) xsane.negative = 0; xsane.show_preview = 1; + xsane.enable_color_management = 0; + fd = open(filename, O_RDONLY); + if (fd >= 0) { /* prepare wire */ @@ -562,6 +565,17 @@ void xsane_device_preferences_load_file(char *filename) } } } + + if (!xsane.scanner_default_color_icm_profile) + { + xsane.scanner_default_color_icm_profile = strdup(""); + } + + if (!xsane.scanner_default_gray_icm_profile) + { + xsane.scanner_default_gray_icm_profile = strdup(""); + } + gtk_window_move(GTK_WINDOW(xsane.dialog), xsane.dialog_posx, xsane.dialog_posy); gtk_window_set_default_size(GTK_WINDOW(xsane.dialog), xsane.dialog_width, xsane.dialog_height); diff --git a/src/xsane-multipage-project.c b/src/xsane-multipage-project.c index 3721faa..7d6a565 100644 --- a/src/xsane-multipage-project.c +++ b/src/xsane-multipage-project.c @@ -968,7 +968,7 @@ static void xsane_multipage_save_file() if (output_format == XSANE_PS) { - xsane_save_ps_create_document_header(outfile, pages, preferences.save_ps_flatedecoded); + xsane_save_ps_create_document_header(outfile, pages, 0, 0, 72.0*9, 72.0*12, 0 /* portrait top left */, preferences.save_ps_flatedecoded); } else if (output_format == XSANE_PDF) { @@ -1088,7 +1088,7 @@ static void xsane_multipage_save_file() imagefile, &image_info, imagewidth, imageheight, 0, 0, imagewidth, imageheight, 0 /* portrait top left */, preferences.save_ps_flatedecoded, - NULL /* hTransform */, 0 /* embed_scanner_icm_profile */, + NULL /* hTransform */, 0 /* embed_scanner_icm_profile */, 0 /* embed CSA */, NULL, /* CSA profile */ 0 /* intent */, xsane.project_progress_bar, &cancel_save); } else if (output_format == XSANE_PDF) diff --git a/src/xsane-preferences.c b/src/xsane-preferences.c index 2705477..9747404 100644 --- a/src/xsane-preferences.c +++ b/src/xsane-preferences.c @@ -302,7 +302,7 @@ desc_printer[] = {"printer-ps-flatedecoded", xsane_rc_pref_int, PRTOFFSET(ps_flatedecoded)}, {"printer-embed-csa", xsane_rc_pref_int, PRTOFFSET(embed_csa)}, {"printer-embed-crd", xsane_rc_pref_int, PRTOFFSET(embed_crd)}, - {"printer-bpc", xsane_rc_pref_int, PRTOFFSET(blackpointcompensation)} + {"printer-cms-bpc", xsane_rc_pref_int, PRTOFFSET(cms_bpc)} }; /* --------------------------------------------------------------------- */ diff --git a/src/xsane-preferences.h b/src/xsane-preferences.h index 916df37..228548e 100644 --- a/src/xsane-preferences.h +++ b/src/xsane-preferences.h @@ -52,7 +52,7 @@ typedef struct int ps_flatedecoded; /* flatedecode (zlib compression), ps level 3 */ int embed_csa; /* CSA = scanner ICM profile for postscript files */ int embed_crd; /* CRD = printer ICM profile for postscript files */ - int blackpointcompensation; /* bpc */ + int cms_bpc; /* bpc */ } Preferences_printer_t; diff --git a/src/xsane-save.c b/src/xsane-save.c index cc5f934..0109a2c 100644 --- a/src/xsane-save.c +++ b/src/xsane-save.c @@ -2387,10 +2387,30 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in /* ---------------------------------------------------------------------------------------------------------------------- */ -void xsane_save_ps_create_document_header(FILE *outfile, int pages, int flatedecode) +void xsane_save_ps_create_document_header(FILE *outfile, int pages, + int paper_left_margin, int paper_bottom_margin, + int paper_width, int paper_height, + int paper_orientation, int flatedecode) { + int box_left, box_bottom, box_right, box_top; + DBG(DBG_proc, "xsane_save_ps_create_document_header\n"); + if (paper_orientation >= 8) /* rotate with 90 degrees - landscape mode */ + { + box_left = paper_width - paper_left_margin - paper_height; + box_bottom = paper_bottom_margin; + box_right = box_left + ceil(paper_height); + box_top = box_bottom + ceil(paper_width); + } + else /* do not rotate, portrait mode */ + { + box_left = paper_left_margin; + box_bottom = paper_bottom_margin; + box_right = box_left + ceil(paper_width); + box_top = box_bottom + ceil(paper_height); + } + fprintf(outfile, "%%!PS-Adobe-3.0\n"); fprintf(outfile, "%%%%Creator: XSane version %s (sane %d.%d) - by Oliver Rauch\n", VERSION, SANE_VERSION_MAJOR(xsane.sane_backend_versioncode), @@ -2405,6 +2425,8 @@ void xsane_save_ps_create_document_header(FILE *outfile, int pages, int flatedec fprintf(outfile, "%%%%LanguageLevel: 2\n"); } + fprintf(outfile, "%%%%BoundingBox: %d %d %d %d\n", box_left, box_bottom, box_right, box_top); + if (pages) { fprintf(outfile, "%%%%Pages: %d\n", pages); @@ -2415,8 +2437,9 @@ void xsane_save_ps_create_document_header(FILE *outfile, int pages, int flatedec } fprintf(outfile, "%%%%EndComments\n"); + fprintf(outfile, "%%%%BeginDocument: xsane.ps\n"); fprintf(outfile, "\n"); - fprintf(outfile, "/origstate save def\n"); +// fprintf(outfile, "/origstate save def\n"); fprintf(outfile, "20 dict begin\n"); } @@ -2427,7 +2450,7 @@ void xsane_save_ps_create_document_trailer(FILE *outfile, int pages) DBG(DBG_proc, "xsane_save_ps_create_document_trailer\n"); fprintf(outfile, "end\n"); - fprintf(outfile, "origstate restore\n"); +// fprintf(outfile, "origstate restore\n"); if (pages) { @@ -2436,102 +2459,21 @@ void xsane_save_ps_create_document_trailer(FILE *outfile, int pages) } fprintf(outfile, "%%%%EOF\n"); + fprintf(outfile, "%%%%EndDocument\n"); fprintf(outfile, "\n"); } /* ---------------------------------------------------------------------------------------------------------------------- */ -/* page = [1 .. pages] */ -static void xsane_save_ps_create_page_header(FILE *outfile, int page, - Image_info *image_info, - float width, float height, - int paper_left_margin, int paper_bottom_margin, - int paper_width, int paper_height, - int paper_orientation, int flatedecode, - GtkProgressBar *progress_bar) +static void xsane_save_ps_create_image_header(FILE *outfile, + Image_info *image_info, + float width, float height, + int degree, int position_left, int position_bottom, + int box_left, int box_bottom, int box_right, int box_top, + int flatedecode) { - int degree, position_left, position_bottom, box_left, box_bottom, box_right, box_top, depth; - int left, bottom; - - DBG(DBG_proc, "xsane_save_ps_create_page_header\n"); - - switch (paper_orientation) - { - default: - case 0: /* top left portrait */ - left = 0.0; - bottom = paper_height - height; - break; - - case 1: /* top right portrait */ - left = paper_width - width; - bottom = paper_height - height; - break; - - case 2: /* bottom right portrait */ - left = paper_width - width; - bottom = 0.0; - break; - - case 3: /* bottom left portrait */ - left = 0.0; - bottom = 0.0; - break; - - case 4: /* center portrait */ - left = paper_width / 2.0 - width / 2.0; - bottom = paper_height / 2.0 - height / 2.0; - break; - - - case 8: /* top left landscape */ - left = 0.0; - bottom = paper_width - height; - break; - - case 9: /* top right landscape */ - left = paper_height - width; - bottom = paper_width - height; - break; - - case 10: /* bottom right landscape */ - left = paper_height - width; - bottom = 0.0; - break; - - case 11: /* bottom left landscape */ - left = 0.0; - bottom = 0.0; - break; - - case 12: /* center landscape */ - left = paper_height / 2.0 - width / 2.0; - bottom = paper_width / 2.0 - height / 2.0; - break; - } - - - if (paper_orientation >= 8) /* rotate with 90 degrees - landscape mode */ - { - degree = 90; - position_left = left + paper_bottom_margin; - position_bottom = bottom - paper_width - paper_left_margin; - box_left = paper_width - paper_left_margin - bottom - height; - box_bottom = left + paper_bottom_margin; - box_right = box_left + ceil(height); - box_top = box_bottom + ceil(width); - } - else /* do not rotate, portrait mode */ - { - degree = 0; - position_left = left + paper_left_margin; - position_bottom = bottom + paper_bottom_margin; - box_left = left + paper_left_margin; - box_bottom = bottom + paper_bottom_margin; - box_right = box_left + ceil(width); - box_top = box_bottom + ceil(height); - } + int depth; depth = image_info->depth; @@ -2540,10 +2482,6 @@ static void xsane_save_ps_create_page_header(FILE *outfile, int page, depth = 12; } - fprintf(outfile, "\n"); - fprintf(outfile, "%%%%Page: %d %d\n", page, page); - fprintf(outfile, "%%%%PageBoundingBox: %d %d %d %d\n", box_left, box_bottom, box_right, box_top); - if (depth == 1) { fprintf(outfile, "/grays %d string def\n", image_info->image_width); @@ -2554,12 +2492,20 @@ static void xsane_save_ps_create_page_header(FILE *outfile, int page, fprintf(outfile, "%d rotate\n", degree); fprintf(outfile, "%d %d translate\n", position_left, position_bottom); fprintf(outfile, "%f %f scale\n", width, height); + fprintf(outfile, "<<\n"); fprintf(outfile, " /ImageType 1\n"); fprintf(outfile, " /Width %d\n", image_info->image_width); fprintf(outfile, " /Height %d\n", image_info->image_height); fprintf(outfile, " /BitsPerComponent %d\n", depth); - fprintf(outfile, " /Decode [0 1 0 1 0 1]\n"); + if (image_info->channels == 3) + { + fprintf(outfile, " /Decode [0 1 0 1 0 1]\n"); + } + else + { + fprintf(outfile, " /Decode [0 1]\n"); + } fprintf(outfile, " /ImageMatrix [%d %d %d %d %d %d]\n", image_info->image_width, 0, 0, -image_info->image_height, 0, image_info->image_height); fprintf(outfile, " /DataSource currentfile /ASCII85Decode filter"); #ifdef HAVE_LIBZ @@ -3033,7 +2979,7 @@ static int xsane_write_CSA(FILE *outfile, char *input_profile, int intent) /* ---------------------------------------------------------------------------------------------------------------------- */ -static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int blackpointcompensation) +static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int cms_bpc) { cmsHPROFILE hProfile; size_t n; @@ -3046,7 +2992,7 @@ static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int return -1; } - if (blackpointcompensation) + if (cms_bpc) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } @@ -3128,10 +3074,12 @@ static int xsane_save_ps_pdf_bw(FILE *outfile, FILE *imagefile, Image_info *imag ret = xsane_write_compressed_a85(outfile, line, bytes_per_line, (y == image_info->image_height - 1)); } } +#ifdef HAVE_LIBZ else if (flatedecode) { ret = xsane_write_flatedecode(outfile, line, bytes_per_line, (y == image_info->image_height - 1)); } +#endif else { fwrite(line, bytes_per_line, 1, outfile); @@ -3230,10 +3178,12 @@ static int xsane_save_ps_pdf_gray(FILE *outfile, FILE *imagefile, Image_info *im ret = xsane_write_compressed_a85(outfile, line, image_info->image_width, (y == image_info->image_height - 1)); } } +#ifdef HAVE_LIBZ else if (flatedecode) { ret = xsane_write_flatedecode(outfile, line, image_info->image_width, (y == image_info->image_height - 1)); } +#endif else { fwrite(line, image_info->image_width, 1, outfile); @@ -3477,10 +3427,12 @@ static int xsane_save_ps_pdf_color(FILE *outfile, FILE *imagefile, Image_info *i ret = xsane_write_compressed_a85(outfile, line, bytes_per_line, (y == image_info->image_height - 1)); } } +#ifdef HAVE_LIBZ else if (flatedecode) { ret = xsane_write_flatedecode(outfile, line, bytes_per_line, (y == image_info->image_height - 1)); } +#endif else { fwrite(line, bytes_per_line, 1, outfile); @@ -3533,18 +3485,119 @@ static int xsane_save_ps_pdf_color(FILE *outfile, FILE *imagefile, Image_info *i int xsane_save_ps_page(FILE *outfile, int page, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, - cmsHTRANSFORM hTransform, int do_transform, + cmsHTRANSFORM hTransform, int apply_ICM_profile, int embed_CSA, char *CSA_profile, int intent, GtkProgressBar *progress_bar, int *cancel_save) { + int degree, position_left, position_bottom, box_left, box_bottom, box_right, box_top; + int left, bottom; + DBG(DBG_proc, "xsane_save_ps_page\n"); - xsane_save_ps_create_page_header(outfile, page, - image_info, width, height, - paper_left_margin, paper_bottom_margin, paperwidth, paperheight, paper_orientation, - flatedecode, - progress_bar); + switch (paper_orientation) + { + default: + case 0: /* top left portrait */ + left = 0.0; + bottom = paper_height - height; + break; + + case 1: /* top right portrait */ + left = paper_width - width; + bottom = paper_height - height; + break; + + case 2: /* bottom right portrait */ + left = paper_width - width; + bottom = 0.0; + break; + + case 3: /* bottom left portrait */ + left = 0.0; + bottom = 0.0; + break; + + case 4: /* center portrait */ + left = paper_width / 2.0 - width / 2.0; + bottom = paper_height / 2.0 - height / 2.0; + break; + + + case 8: /* top left landscape */ + left = 0.0; + bottom = paper_width - height; + break; + + case 9: /* top right landscape */ + left = paper_height - width; + bottom = paper_width - height; + break; + + case 10: /* bottom right landscape */ + left = paper_height - width; + bottom = 0.0; + break; + + case 11: /* bottom left landscape */ + left = 0.0; + bottom = 0.0; + break; + + case 12: /* center landscape */ + left = paper_height / 2.0 - width / 2.0; + bottom = paper_width / 2.0 - height / 2.0; + break; + } + + + if (paper_orientation >= 8) /* rotate with 90 degrees - landscape mode */ + { + degree = 90; + position_left = left + paper_bottom_margin; + position_bottom = bottom - paper_width - paper_left_margin; + box_left = paper_width - paper_left_margin - bottom - height; + box_bottom = left + paper_bottom_margin; + box_right = box_left + ceil(height); + box_top = box_bottom + ceil(width); + } + else /* do not rotate, portrait mode */ + { + degree = 0; + position_left = left + paper_left_margin; + position_bottom = bottom + paper_bottom_margin; + box_left = left + paper_left_margin; + box_bottom = bottom + paper_bottom_margin; + box_right = box_left + ceil(width); + box_top = box_bottom + ceil(height); + } + + fprintf(outfile, "\n"); + fprintf(outfile, "%%%%Page: %d %d\n", page, page); + fprintf(outfile, "%%%%PageBoundingBox: %d %d %d %d\n", box_left, box_bottom, box_right, box_top); + +#ifdef HAVE_LIBLCMS + if ((apply_ICM_profile) && (embed_CSA)) + { + xsane_write_CSA(outfile, CSA_profile, intent); /* write scanner profile to ps file */ + } + else +#endif + { + if (image_info->channels == 1) /* lineart, halftone, grayscale */ + { + fprintf(outfile, "/DeviceGray setcolorspace\n"); + } + else + { + fprintf(outfile, "/DeviceRGB setcolorspace\n"); + } + } + + xsane_save_ps_create_image_header(outfile, image_info, width, height, + degree, position_left, position_bottom, + box_left, box_bottom, box_right, box_top, + flatedecode); if (image_info->channels == 1) /* lineart, halftone, grayscale */ { @@ -3554,12 +3607,12 @@ int xsane_save_ps_page(FILE *outfile, int page, } else /* grayscale */ { - xsane_save_ps_pdf_gray(outfile, imagefile, image_info, TRUE, flatedecode, hTransform, do_transform, progress_bar, cancel_save); + xsane_save_ps_pdf_gray(outfile, imagefile, image_info, TRUE, flatedecode, hTransform, apply_ICM_profile && (!embed_CSA), progress_bar, cancel_save); } } else /* color RGB */ { - xsane_save_ps_pdf_color(outfile, imagefile, image_info, TRUE, flatedecode, hTransform, do_transform, progress_bar, cancel_save); + xsane_save_ps_pdf_color(outfile, imagefile, image_info, TRUE, flatedecode, hTransform, apply_ICM_profile && (!embed_CSA), progress_bar, cancel_save); } xsane_save_ps_create_page_trailer(outfile); @@ -3580,47 +3633,32 @@ int xsane_save_ps_page(FILE *outfile, int page, /* ---------------------------------------------------------------------------------------------------------------------- */ int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int apply_ICM_profile, int embed_CSA, char *CSA_profile, - int embed_CRD, char *CRD_profile, int blackpointcompensation, int intent, + int embed_CRD, char *CRD_profile, int cms_bpc, int intent, GtkProgressBar *progress_bar, int *cancel_save) { DBG(DBG_proc, "xsane_save_ps\n"); *cancel_save = 0; - xsane_save_ps_create_document_header(outfile, 1 /* pages */, flatedecode); + xsane_save_ps_create_document_header(outfile, 1 /* pages */, paper_left_margin, paper_bottom_margin, paper_width, paper_height, paper_orientation, flatedecode); #ifdef HAVE_LIBLCMS if ((apply_ICM_profile) && (embed_CRD)) { - xsane_write_CRD(outfile, CRD_profile, intent, blackpointcompensation); /* write printer profile to ps file */ + xsane_write_CRD(outfile, CRD_profile, intent, cms_bpc); /* write printer profile to ps file */ } +#endif - if ((apply_ICM_profile) && (embed_CSA)) - { - xsane_write_CSA(outfile, CSA_profile, intent); /* write scanner profile to ps file */ - } - else -#endif - { - if (image_info->channels == 1) /* lineart, halftone, grayscale */ - { - fprintf(outfile, "/DeviceGray setcolorspace\n"); - } - else - { - fprintf(outfile, "/DeviceRGB setcolorspace\n"); - } - } xsane_save_ps_page(outfile, 1 /* page */, imagefile, image_info, width, height, - paper_left_margin, paper_bottom_margin, paperwidth, paperheight, paper_orientation, + paper_left_margin, paper_bottom_margin, paper_width, paper_height, paper_orientation, flatedecode, - hTransform, (apply_ICM_profile && (!embed_CSA) && (!embed_CRD)) /* do_transform */, + hTransform, apply_ICM_profile, embed_CSA, CSA_profile, intent, progress_bar, cancel_save); xsane_save_ps_create_document_trailer(outfile, 0 /* we defined pages at beginning */); @@ -4020,7 +4058,7 @@ static void xsane_save_pdf_create_page_trailer(FILE *outfile, struct pdf_xref *x int xsane_save_pdf_page(FILE *outfile, struct pdf_xref *xref, int page, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int do_transform, int icc_object, GtkProgressBar *progress_bar, int *cancel_save) @@ -4030,7 +4068,7 @@ int xsane_save_pdf_page(FILE *outfile, struct pdf_xref *xref, int page, xsane_save_pdf_create_page_header(outfile, xref, page, image_info, width, height, - paper_left_margin, paper_bottom_margin, paperwidth, paperheight, paper_orientation, + paper_left_margin, paper_bottom_margin, paper_width, paper_height, paper_orientation, flatedecode, icc_object, progress_bar); @@ -4068,7 +4106,7 @@ int xsane_save_pdf_page(FILE *outfile, struct pdf_xref *xref, int page, /* ---------------------------------------------------------------------------------------------------------------------- */ int xsane_save_pdf(FILE *outfile, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int apply_ICM_profile, int cms_function, GtkProgressBar *progress_bar, int *cancel_save) @@ -4093,7 +4131,7 @@ int xsane_save_pdf(FILE *outfile, FILE *imagefile, Image_info *image_info, float xsane_save_pdf_page(outfile, &xref, 1, imagefile, image_info, width, height, - paper_left_margin, paper_bottom_margin, paperwidth, paperheight, paper_orientation, + paper_left_margin, paper_bottom_margin, paper_width, paper_height, paper_orientation, flatedecode, hTransform, apply_ICM_profile && ((cms_function != XSANE_CMS_FUNCTION_EMBED_SCANNER_ICM_PROFILE)) /* do_transform */, icc_object, progress_bar, cancel_save); diff --git a/src/xsane-save.h b/src/xsane-save.h index f94fe7c..64db676 100644 --- a/src/xsane-save.h +++ b/src/xsane-save.h @@ -68,17 +68,20 @@ extern int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *i extern int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int radius, GtkProgressBar *progress_bar, int *cancel_save); extern int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float radius, GtkProgressBar *progress_bar, int *cancel_save); extern int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int rotation, GtkProgressBar *progress_bar, int *cancel_save); -extern void xsane_save_ps_create_document_header(FILE *outfile, int pages, int flatedecode); +extern void xsane_save_ps_create_document_header(FILE *outfile, int pages, + int paper_left_margin, int paper_bottom_margin, + int paper_width, int paper_height, + int paper_orientation, int flatedecode); extern void xsane_save_ps_create_document_trailer(FILE *outfile, int pages); extern int xsane_save_ps_page(FILE *outfile, int page, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, - cmsHTRANSFORM hTransform, int embed_scanner_icm_profile, + cmsHTRANSFORM hTransform, int apply_ICM_profile, int embed_CSA, char *CSA_profile, int intent, GtkProgressBar *progress_bar, int *cancel_save); extern int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int apply_ICM_profile, int embed_CSA, char *CSA_profile, int embed_CRD, char *CRD_profile, int blackpointcompensation, int intent, @@ -87,13 +90,13 @@ extern void xsane_save_pdf_create_document_header(FILE *outfile, struct pdf_xref extern void xsane_save_pdf_create_document_trailer(FILE *outfile, struct pdf_xref *xref, int pages); extern int xsane_save_pdf_page(FILE *outfile, struct pdf_xref *xref, int page, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int embed__scanner_icm_profile, int icc_object, GtkProgressBar *progress_bar, int *cancel_save); extern int xsane_save_pdf(FILE *outfile, FILE *imagefile, Image_info *image_info, float width, float height, - int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation, + int paper_left_margin, int paper_bottom_margin, int paper_width, int paper_height, int paper_orientation, int flatedecode, cmsHTRANSFORM hTransform, int apply_ICM_profile, int cms_function, GtkProgressBar *progress_bar, int *cancel_save); diff --git a/src/xsane-scan.c b/src/xsane-scan.c index 9cc9ffb..11aff3e 100644 --- a/src/xsane-scan.c +++ b/src/xsane-scan.c @@ -1090,7 +1090,23 @@ void xsane_scan_done(SANE_Status status) image_info.cms_intent = preferences.cms_intent; image_info.cms_bpc = preferences.cms_bpc; - strncpy(image_info.icm_profile, xsane.scanner_default_color_icm_profile, sizeof(image_info.icm_profile)); + image_info.icm_profile[0] = 0; /* empty string */ + + if (image_info.channels == 1) + { + if (xsane.scanner_default_gray_icm_profile) + { + strncpy(image_info.icm_profile, xsane.scanner_default_gray_icm_profile, sizeof(image_info.icm_profile)); + } + } + else + { + if (xsane.scanner_default_color_icm_profile) + { + strncpy(image_info.icm_profile, xsane.scanner_default_color_icm_profile, sizeof(image_info.icm_profile)); + } + } + xsane_write_pnm_header(xsane.out, &image_info, 0); } @@ -1349,13 +1365,13 @@ void xsane_scan_done(SANE_Status status) imagewidth, imageheight, preferences.printer[preferences.printernr]->leftoffset * 72.0/MM_PER_INCH, /* paper_left_margin */ preferences.printer[preferences.printernr]->bottomoffset * 72.0/MM_PER_INCH, /* paper_bottom_margin */ - preferences.printer[preferences.printernr]->width * 72.0/MM_PER_INCH, /* usable paperwidth */ - preferences.printer[preferences.printernr]->height * 72.0/MM_PER_INCH, /* usable paperheight */ + preferences.printer[preferences.printernr]->width * 72.0/MM_PER_INCH, /* usable paper_width */ + preferences.printer[preferences.printernr]->height * 72.0/MM_PER_INCH, /* usable paper_height */ preferences.paper_orientation, preferences.printer[preferences.printernr]->ps_flatedecoded, /* ps level 3 */ NULL /* hTransform */, xsane.enable_color_management, preferences.printer[preferences.printernr]->embed_csa, xsane.scanner_default_color_icm_profile, - preferences.printer[preferences.printernr]->embed_crd, preferences.printer[preferences.printernr]->icm_profile, preferences.printer[preferences.printernr]->blackpointcompensation, + preferences.printer[preferences.printernr]->embed_crd, preferences.printer[preferences.printernr]->icm_profile, preferences.printer[preferences.printernr]->cms_bpc, 0 /* intent */, xsane.progress_bar, &xsane.cancel_save); @@ -1769,7 +1785,23 @@ static void xsane_start_scan(void) image_info.cms_intent = preferences.cms_intent; image_info.cms_bpc = preferences.cms_bpc; - strncpy(image_info.icm_profile, xsane.scanner_default_color_icm_profile, sizeof(image_info.icm_profile)); + + image_info.icm_profile[0] = 0; /* empty string */ + + if (image_info.channels == 1) + { + if (xsane.scanner_default_gray_icm_profile) + { + strncpy(image_info.icm_profile, xsane.scanner_default_gray_icm_profile, sizeof(image_info.icm_profile)); + } + } + else + { + if (xsane.scanner_default_color_icm_profile) + { + strncpy(image_info.icm_profile, xsane.scanner_default_color_icm_profile, sizeof(image_info.icm_profile)); + } + } xsane_write_pnm_header(xsane.out, &image_info, 0); diff --git a/src/xsane-setup.c b/src/xsane-setup.c index 677c375..1078604 100644 --- a/src/xsane-setup.c +++ b/src/xsane-setup.c @@ -141,6 +141,7 @@ void xsane_new_printer(void) preferences.printer[preferences.printernr]->icm_profile = NULL; preferences.printer[preferences.printernr]->embed_csa = 1; preferences.printer[preferences.printernr]->embed_crd = 0; + preferences.printer[preferences.printernr]->cms_bpc = 0; preferences.printer[preferences.printernr]->ps_flatedecoded = 1; } else @@ -294,6 +295,7 @@ static void xsane_setup_printer_update() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(xsane_setup.printer_embed_csa_button), preferences.printer[preferences.printernr]->embed_csa); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(xsane_setup.printer_embed_crd_button), preferences.printer[preferences.printernr]->embed_crd); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(xsane_setup.printer_cms_bpc_button), preferences.printer[preferences.printernr]->cms_bpc); #endif #ifdef HAVE_LIBZ @@ -383,6 +385,7 @@ static void xsane_setup_printer_apply_changes(GtkWidget *widget, gpointer data) preferences.printer[preferences.printernr]->icm_profile = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.printer_icm_profile_entry))); xsane_update_bool(xsane_setup.printer_embed_csa_button, &preferences.printer[preferences.printernr]->embed_csa); xsane_update_bool(xsane_setup.printer_embed_crd_button, &preferences.printer[preferences.printernr]->embed_crd); + xsane_update_bool(xsane_setup.printer_cms_bpc_button, &preferences.printer[preferences.printernr]->cms_bpc); #endif #ifdef HAVE_LIBZ @@ -1451,6 +1454,18 @@ static void xsane_printer_notebook(GtkWidget *notebook) gtk_widget_show(button); gtk_widget_show(hbox); xsane_setup.printer_embed_crd_button = button; + + /* black point compensation */ + hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2); + button = gtk_check_button_new_with_label(TEXT_SETUP_PRINTER_CMS_BPC); + xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PRINTER_CMS_BPC); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), preferences.printer[preferences.printernr]->cms_bpc); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 2); + gtk_widget_show(button); + gtk_widget_show(hbox); + xsane_setup.printer_cms_bpc_button = button; + #endif #ifdef HAVE_LIBZ diff --git a/src/xsane-text.h b/src/xsane-text.h index c271956..59c6317 100644 --- a/src/xsane-text.h +++ b/src/xsane-text.h @@ -287,6 +287,7 @@ #define TEXT_SETUP_PRINTER_GAMMA_BLUE _("Printer gamma blue:") #define TEXT_SETUP_PRINTER_EMBED_CSA _("Embed scanner ICM profile as CSA") #define TEXT_SETUP_PRINTER_EMBED_CRD _("Embed printer ICM profile as CRD") +#define TEXT_SETUP_PRINTER_CMS_BPC _("Apply black point compensation") #define TEXT_SETUP_PRINTER_PS_FLATEDECODED _("Create zlib compressed postscript image (ps level 3) for printing") #define TEXT_SETUP_TMP_PATH _("Temporary directory") #define TEXT_SETUP_IMAGE_PERMISSION _("Image-file permissions") @@ -578,6 +579,7 @@ #define DESC_PRINTER_GAMMA_BLUE _("Additional gamma value for blue component for photocopy") #define DESC_PRINTER_EMBED_CSA _("Creates a postsciptfile that contains the ICM profile of the scanner") #define DESC_PRINTER_EMBED_CRD _("Creates a postsciptfile that contains the ICM profile of the printer") +#define DESC_PRINTER_CMS_BPC _("Applies black point compensation") #define DESC_PRINTER_PS_FLATEDECODED _("Create zlib compressed postscript image for printer (flatedecode).\n" \ "The printer has to understand postscript level 3!") #define DESC_TMP_PATH _("Path to temp directory") diff --git a/src/xsane.h b/src/xsane.h index 4e4ddd8..5cde44a 100644 --- a/src/xsane.h +++ b/src/xsane.h @@ -91,7 +91,7 @@ /* ---------------------------------------------------------------------------------------------------------------------- */ -#define XSANE_VERSION "0.993" +#define XSANE_VERSION "0.994" #define XSANE_AUTHOR "Oliver Rauch" #define XSANE_COPYRIGHT "Oliver Rauch" #define XSANE_DATE "1998-2007" @@ -1010,6 +1010,7 @@ typedef struct XsaneSetup GtkWidget *printer_icm_profile_entry; GtkWidget *printer_embed_csa_button; GtkWidget *printer_embed_crd_button; + GtkWidget *printer_cms_bpc_button; GtkWidget *printer_width_entry; GtkWidget *printer_height_entry; GtkWidget *printer_ps_flatedecoded_button; -- cgit v1.2.3