Bug 693566

Summary: devn_get_params returns mostly incorrect values
Product: Ghostscript Reporter: Ray Johnston <ray.johnston>
Component: ColorAssignee: Default assignee <ghostpdl-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: sphinx.pinastri
Priority: P4    
Version: master   
Hardware: PC   
OS: Windows 7   
Customer: Word Size: ---

Description Ray Johnston 2013-01-17 14:19:19 UTC
I recently modified devn_get_params to return PageSpotColors since I needed
that to get color_info.max_components set correctly (see bug 693557), but
noticed that this function just returns dummy functions. In general, the
goal is to be able put deviceparams and then read back the same ones with
get.

For reference, the code (with my modification for PageSpotColors) is:
{
    int code;
    bool seprs = false;
    gs_param_string_array scna;
    gs_param_string_array sona;

    set_param_array(scna, NULL, 0);
    set_param_array(sona, NULL, 0);

    if ( (code = sample_device_crd_get_params(pdev, plist, "CRDDefault")) < 0 ||
         (code =
            param_write_name_array(plist, "SeparationColorNames", &scna)) < 0 ||
         (code = param_write_name_array(plist, "SeparationOrder", &sona)) < 0 ||
         (code = param_write_bool(plist, "Separations", &seprs)) < 0 ||
         (code = param_write_int(plist, "PageSpotColors", &(pdevn_params->page_spot_colors))) < 0)
        return code;

    return 0;
}

Unless I am missing something, this always returns empty arrays for the
SeparationColorNames and SeparationOrder and always returns 'false' for
Separations.

Doesn't seem right to me.
Comment 1 Michael Vrhel 2019-01-28 19:03:41 UTC
Do we have a test file that has a CRD so that we can exercise this bit of code?  I think since we have gone to a pure ICC workflow this bit of code could probably be removed.
Comment 2 Peter Cherepanov 2021-02-14 00:53:05 UTC
This seems to work now. The following program

/dump { % dict /key -> dict
  dup ==only ( ) =only
  2 copy known { 2 copy get == pop }{(none)== } ifelse
} bind def

/params {
  currentpagedevice
  {/Separations/ProcessColorModel/SeparationColorNames/SeparationOrder
   /PageSpotColors/CRDDefault} //dump forall pop
} bind def

params
<< /SeparationColorNames [/Cyan/Magenta/Yellow/Black/Pink/Rainbow]
   /SeparationOrder 1 index
   /PageSpotColors 2
>> setpagedevice
params
showpage

Prints

~/ghostpdl/debugbin/gs -q -sDEVICE=tiffsep -o a.tiff devn.ps 
/Separations false
/ProcessColorModel /DeviceCMYK
/SeparationColorNames []
/SeparationOrder []
/PageSpotColors -1
/CRDDefault (none)
/Separations false
/ProcessColorModel /DeviceCMYK
/SeparationColorNames [/Cyan /Magenta /Yellow /Black /Pink /Rainbow]
/SeparationOrder [/Cyan /Magenta /Yellow /Black /Pink /Rainbow]
/PageSpotColors 2
/CRDDefault (none)
Comment 3 Ken Sharp 2023-05-11 10:38:58 UTC
Closing as per Peter's comment #2