From dfacacb6b73255a4c0364f4cfcd4edbe3c2ddddc Mon Sep 17 00:00:00 2001 From: Nathan Muggli Date: Fri, 7 Feb 2025 09:18:56 -0700 Subject: [PATCH] Update Ink option Don't use PPD file to update Ink option Corresponds to patch 1.7.6-cupsRasterHeader from ChromeOS. --- src/filter.c | 9 +++++++++ src/wrapper.c | 22 ++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/filter.c b/src/filter.c index 680ba85..aac4d64 100644 --- a/src/filter.c +++ b/src/filter.c @@ -336,9 +336,18 @@ main (int argc, char *argv[]) band_line = 1; if (strcmp (fopt.ink, "COLOR") == 0) + { byte_par_pixel = 3; + } + else if (strcmp (fopt.ink, "MONO") == 0) + { + byte_par_pixel = 1; + } else + { + fprintf(stderr, "ERROR: [escpr] raster data is handled as 8bpp, unknown option\n"); byte_par_pixel = 1; + } /////////////////////////////////////////////////////////////////////////////////////////////////////////// epsInitLib(); diff --git a/src/wrapper.c b/src/wrapper.c index b3594df..8603a7a 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -205,6 +205,19 @@ main (int argc, char *argv[]) int ret; ret = cupsRasterReadHeader (ras, &header); + if (header.cupsBitsPerPixel == 24 && header.cupsColorSpace == 1) + { + strcpy (fopt.ink, "COLOR"); + } + else if (header.cupsBitsPerPixel == 8 && header.cupsColorSpace == 0) + { + strcpy (fopt.ink, "MONO"); + } + else + { + strcpy (fopt.ink, "NOT_SUPPORTED"); + } + if (ret == 0 && customsize_flag) break; //カスタムサイズのときはキャッシュしない if (ret == 0 || cancel_flg) //データをすべて読み終わった @@ -409,14 +422,7 @@ get_option_for_ppd (const char *printer, filter_option_t *filter_opt_p) } /* ink */ - if (filter_opt_p->ink[0] == '\0') - { - opt = get_default_choice (ppd_p, "Ink"); - if (!opt) - return 1; - - strcpy (filter_opt_p->ink, opt); - } + // Don't touch Ink key. /* MediaType */ if (filter_opt_p->quality[0] == '\0') -- 2.48.1.502.g6dc24dfdaf-goog