Skip to content

Compatibility with the old .setopacityalpha and new .setfillconstantalpha/.setalphaisshape PostScript  #4453

Closed

Description

@seisman

The issue was discussed in another issue #3282. Here I open a separate issue for better discussions.


Just build their master branch. The transparency bug in 9.51 and 9.52 is fixed. Now I can see transparency in PDF, JPG and PNG.

However, I get the following warnings for transparent plots:

   **** WARNING: .setopacityalpha is deprecated (as of 9.53) and will be removed in a future release
   **** See .setfillconstantalpha/.setalphaisshape for the improved solution

Originally posted by @seisman in #3282 (comment)


This is a threat for us, so we need to figure out how to rewrite the PSL_transp PostScript function that is defined in the PSL_strings.h include file. I have yet to find any documentation on .setfillconstantalpha and how to use it. Just replacing .setopacityalpha with . setfillconstantalpha did not seem to wark (no errors, but no transparency). We will need to research this more to better document how we do this, possibly asking the gs people for advice.

Originally posted by @PaulWessel in #3282 (comment)


Comparing the 9.52 documentation and the "master/dev" documentation, it seems .setfillconstantalpha/.setalphaisshape are added in 9.53.

Originally posted by @seisman in #3282 (comment)


Just replacing .setopacityalpha with . setfillconstantalpha did not seem to wark (no errors, but no transparency).

It works for me with gs 9.53 (built from their master a few days ago). It doesn't work for you possibly because you're still using 9.50?

Originally posted by @seisman in #3282 (comment)


Yes. So we cannot drop it in yet, but also cannot wait until they drop support. I guess we need a way to issue the right code based on gs version. Have to think about how that should be done, maybe with a bit-flag passed into PSL_plotinit.

Originally posted by @PaulWessel in #3282 (comment)

Activity

  1. PaulWessel commented on Nov 18, 2020

    @PaulWessel
    Contributor

    We have one PostScript function we call PSL_transp that looks like this:

    /PSL_transp {
      /.setopacityalpha where {pop .setblendmode .setopacityalpha}{
      /pdfmark where {pop [ /BM exch /CA exch dup /ca exch /SetTransparency pdfmark}
      {pop pop} ifelse} ifelse
    }!
    

    and we call it when needed (e.g., like this to set red (1 0 0 ) with 60% transparency using normal blend mode:)

    {1 0 0 C 0.6 /Normal PSL_transp} FS

    This works but 9.53 gives those ugly warnings. If I change it to this it still works (and no warnings):

    /PSL_transp {
      /.setfillconstantalpha where {pop .setblendmode .setfillconstantalpha}{
      /pdfmark where {pop [ /BM exch /CA exch dup /ca exch /SetTransparency pdfmark}
      {pop pop} ifelse} ifelse
    }!
    

    This is gs 9.53.3. Perhaps @seisman's earlier experiment was with an earlier (and not yet working) version? It seems we should be able to finesse this in the code since we check on gs version and just need to use the older scheme for older versions for awhile. OK?

  2. PaulWessel commented on Nov 18, 2020

    @PaulWessel
    Contributor

    Given that only psconvert checks for gs version, perhaps the solution should be applied there. Given the version we can intercept the .setfillconstantalpha word and replace with .setopacityalpha if version is < 9.53. That way no need to have every GMT process check gs version.

  3. seisman commented on Nov 18, 2020

    @seisman
    MemberAuthor

    I can confirm that changing .setopacityalpha to .setfillconstantalpha works.

    Given the version we can intercept the .setfillconstantalpha word and replace with .setopacityalpha if version is < 9.53.

    If I generate a PS file using GMT 6.2.0, others who uses <=GMT 6.1.1 and gs<9.53 won't be able to convert it to other formats, right?

  4. PaulWessel commented on Nov 19, 2020

    @PaulWessel
    Contributor

    That is true if we do what I suggested. There are no scenarios were everything will work for all. We could leave the PS as is and only update psconvert in 6.2.0 to do the switch if 9.53 is detected. However, anyone running 6.1.1 with an updated gs 9.53 will also have trouble. So two options it seems:

    1. Change master PS code to use . setfillconstantalpha but let psconvert possibly change that to .setopacityalpha if old gs detected. After some time (or perhaps never) we remove that check.
    2. Leave master PS code with .setopacityalpha but let psconvert possibly change that to . setfillconstantalpha if gs is 9.53 or newer. At some future time (or perhaps never) we update the PS and remove the check.

    I can imagine there are people who will get into trouble in both scenarios, and obviously sharing PS files (like your example) may be a problem. Seems to me that we should fix the PS to be compliant but let psconvert help during the transition. Better to have a PS compliant with current gs I think. Do you have better arguments?

  5. seisman commented on Nov 19, 2020

    @seisman
    MemberAuthor

    Better to have a PS compliant with current gs I think.

    Yes, I agree.

  6. added a commit that references this issue on Nov 19, 2020
    ce7fbb2
  7. added a commit that references this issue on Nov 21, 2020
    2d70936
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions