From dabe86b93f67dd40938b77f01b4317da8cb77c9c Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Wed, 17 May 2023 08:43:57 +0100 Subject: Graphics library - create icc_struct when required Bug #703750 "-dRenderIntent=0 not working on linux" For unknown reasons the Windows build calls gx_default_put_params() twice with the same set of parameters. Linux, however only calls it once. The reason this is a problem is because the first time it is called the device's icc_struct member is NULL (not been allocated) and so the put_params call simply discards the request (without warning). On Windows the second request succeeds but since Linux only calls put_params once, it ends up discarding the request entirely. On examining the code it is clear that the gx_default_put_intent() and similar functions all create the device's icc_struct member if it is not already present, so clearly this is a problem which has been encountered before. Since this is the case, there is no need for the guard against dev->icc_struct being NULL in gx_default_put_params() and removing it properly stores the requested parameters. --- base/gsdparam.c | 64 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/base/gsdparam.c b/base/gsdparam.c index 15c2913f9..a605f0f60 100644 --- a/base/gsdparam.c +++ b/base/gsdparam.c @@ -2434,45 +2434,43 @@ label:\ /* Take care of the rendering intents and blackpts. For those that are not set special, the default provides an override */ - if (dev->icc_struct != NULL) { - /* Set the default object */ - code = gx_default_put_intent(rend_intent[0], dev, gsDEFAULTPROFILE); + /* Set the default object */ + code = gx_default_put_intent(rend_intent[0], dev, gsDEFAULTPROFILE); + if (code < 0) + return code; + code = gx_default_put_blackptcomp(blackptcomp[0], dev, gsDEFAULTPROFILE); + if (code < 0) + return code; + code = gx_default_put_blackpreserve(blackpreserve[0], dev, gsDEFAULTPROFILE); + if (code < 0) + return code; + /* If the default was specified and not a specialized one (e.g. graphic + image or text) then the special one will get set to the default. */ + for (k = 1; k < NUM_DEVICE_PROFILES; k++) { + if (rend_intent[0] != gsRINOTSPECIFIED && + rend_intent[k] == gsRINOTSPECIFIED) { + code = gx_default_put_intent(rend_intent[0], dev, profile_types[k]); + } else { + code = gx_default_put_intent(rend_intent[k], dev, profile_types[k]); + } if (code < 0) return code; - code = gx_default_put_blackptcomp(blackptcomp[0], dev, gsDEFAULTPROFILE); + if (blackptcomp[0] != gsBPNOTSPECIFIED && + blackptcomp[k] == gsBPNOTSPECIFIED) { + code = gx_default_put_blackptcomp(blackptcomp[0], dev, profile_types[k]); + } else { + code = gx_default_put_blackptcomp(blackptcomp[k], dev, profile_types[k]); + } if (code < 0) return code; - code = gx_default_put_blackpreserve(blackpreserve[0], dev, gsDEFAULTPROFILE); + if (blackpreserve[0] != gsBKPRESNOTSPECIFIED && + blackpreserve[k] == gsBKPRESNOTSPECIFIED) { + code = gx_default_put_blackpreserve(blackpreserve[0], dev, profile_types[k]); + } else { + code = gx_default_put_blackpreserve(blackpreserve[k], dev, profile_types[k]); + } if (code < 0) return code; - /* If the default was specified and not a specialized one (e.g. graphic - image or text) then the special one will get set to the default. */ - for (k = 1; k < NUM_DEVICE_PROFILES; k++) { - if (rend_intent[0] != gsRINOTSPECIFIED && - rend_intent[k] == gsRINOTSPECIFIED) { - code = gx_default_put_intent(rend_intent[0], dev, profile_types[k]); - } else { - code = gx_default_put_intent(rend_intent[k], dev, profile_types[k]); - } - if (code < 0) - return code; - if (blackptcomp[0] != gsBPNOTSPECIFIED && - blackptcomp[k] == gsBPNOTSPECIFIED) { - code = gx_default_put_blackptcomp(blackptcomp[0], dev, profile_types[k]); - } else { - code = gx_default_put_blackptcomp(blackptcomp[k], dev, profile_types[k]); - } - if (code < 0) - return code; - if (blackpreserve[0] != gsBKPRESNOTSPECIFIED && - blackpreserve[k] == gsBKPRESNOTSPECIFIED) { - code = gx_default_put_blackpreserve(blackpreserve[0], dev, profile_types[k]); - } else { - code = gx_default_put_blackpreserve(blackpreserve[k], dev, profile_types[k]); - } - if (code < 0) - return code; - } } gsicc_setcoloraccuracy(dev->memory, color_accuracy); code = gx_default_put_graytok(devicegraytok, dev); -- cgit v1.2.1