14 Replies Latest reply: Dec 2, 2009 9:17 AM by G_Soucy RSS

    How to Recover Layer Masks From a Format Plugin

    G_Soucy Community Member

      Hi !!

       

      I am writing a format plugin that support multiple layers. Each of the layers can have their own mask (I need to be able to edit those masks).

       

      When I try to save this multiple layers multiple masks image, I dont know how to access the layer mask data from the plugin. Anybody know how to do that? The 4th channel of the layer image is all white and does not look at all like my mask.

       

      If I "apply the mask" to the layer before saving, then I can see the mask as a 4th channel in the plugin. However, by applying the mask, it is not editable anymore and lost forever  :-( .

       

      Thanks!

       

      Gilbert

        • 1. Re: How to Recover Layer Masks From a Format Plugin
          Chris Cox Adobe Employee

          Sounds like you're looking at transparency or alpha channels instead of the layer masks.

           

          You'll need to ask for the additional masks in the parameters, or use channel ports (and still specifically look for the masks).

          • 2. Re: How to Recover Layer Masks From a Format Plugin
            G_Soucy Community Member

            Yes, right now I am looking for the alpha channel.

             

            I am not familiar with the 2 solutions you are proposing. How can I "ask for the additional masks in the parameters" ?  Which parameters are you referring to?

             

            Thanks!

             

            Gilbert

            • 3. Re: How to Recover Layer Masks From a Format Plugin
              Chris Cox Adobe Employee

              The FormatRecord - where you put almost all the parameters/arguments for the format plugin API.

              And read the SDK documentation about channel ports.

              • 4. Re: How to Recover Layer Masks From a Format Plugin
                G_Soucy Community Member

                Hi Chris,

                 

                Thank you. I am now able to get a pointer to the channel port interface suite with:

                 

                 

                PSChannelPortsSuite1 *sPSChannelPorts;

                 

                 

                 

                // Acquiring version 3.

                 

                 

                int error = sSPBasic->AcquireSuite((const char *)kPSChannelPortsSuite,

                                                                       kPSChannelPortsSuiteVersion3,

                                                                       (

                const void**)&sPSChannelPorts);

                 

                 

                My only problem is that each of these routines require a PIChannelPort. How do I get a PIChannelPort for my image?

                 

                Gilbert

                • 5. Re: How to Recover Layer Masks From a Format Plugin
                  Chris Cox Adobe Employee

                  You have that as part of the FormatRecord.

                  You probably should spend a bit more time reading the documentation.

                  • 6. Re: How to Recover Layer Masks From a Format Plugin
                    G_Soucy Community Member

                    Hi Chris,

                     

                    I have the SDK for CS4 and in the doc for FormatRecord ( <root>\documentation\html\struct_format_record.html ) I dont see a PIChannelPort element (I see a  channelPortProcs  which is an old deprecated interface). Looking at the source file   PIFormat.h   does not show any trace of PIChannelPort either. So, it may be in FormatRecord but it must be obtained via a function call and I would appreciate very much if you could tell me how to do that.

                     

                    For the record, I did spend a lot of time reading the documentation but, IMHO, it is incomplete. Nobody can write a plugin from scratch with only the doc and no example. It would be useful if an example for layers, masks and metadata was included in the SDK. It would save people like you a lot of time.

                     

                    Now, if it is in the doc, I sincerely apologize for being blind (I'll ship you a beer with my excuses :-) but could you kindly indicate to me on which page I can find how to get a PIChannelPort for my image given a FormatRecord?

                     

                    Thank you!

                     

                    Gilbert

                    • 7. Re: How to Recover Layer Masks From a Format Plugin
                      Chris Cox Adobe Employee

                      In the formatRecord, right below the channelport procs is ReadImageDocumentDesc *documentInfo;

                      Look at that structure.

                       

                      And many people have written plugins from the documentation without using the example plugins.

                      Though most do modify (and remove the cruft from) examples to get themselves started.

                      • 8. Re: How to Recover Layer Masks From a Format Plugin
                        G_Soucy Community Member

                        Hi Chris!

                         

                        Thanks to your help I have been able to access the layer mask while writing an image.

                         

                        Now, I would like to know if it is possible to add a layer mask while loading an image. The documentInfo pointer is NULL when for all the read events in my plugin (so I cannot get access to the PIChannelPort). I suppose that I missed something in the initialization of the image during the ReadStart event. Could you tell me how I can create a layer mask while loading an image from a Format plugin?

                         

                        Thank you!

                         

                        Gilbert

                        • 9. Re: How to Recover Layer Masks From a Format Plugin
                          Chris Cox Adobe Employee

                          That part I'm not sure about.

                          Tom Ruark added a very different interface for reading in layers.

                          • 10. Re: How to Recover Layer Masks From a Format Plugin
                            G_Soucy Community Member

                            I see. And this interface would not be described in the current doc we have in the SDK? Or I am not looking at the right place in the doc (i.e. we dont interface via the FormatRecord anymore) ?

                             

                            Please let me know what you recommand.

                             

                            Thanks again!

                             

                            Gilbert

                            • 11. Re: How to Recover Layer Masks From a Format Plugin
                              Chris Cox Adobe Employee

                              It's all via the FormatRecord (one way or another), and is documented in the CS4 SDK.

                              • 12. Re: How to Recover Layer Masks From a Format Plugin
                                G_Soucy Community Member

                                Hi Chris,

                                 

                                In a previous posting you had suggested to use

                                 

                                     ReadImageDocumentDesc *documentInfo;

                                 

                                to access the layer mask data while saving a file. That worked fine.  Thank you. However, this structure is set to NULL by Photoshop when reading an image. So, could you kindly indicate me how you recommand creating a layer mask when reading an image since, apparently,  I cannot use the documentInfo structure.

                                 

                                In your previous email, you mentioned :

                                 

                                     "Tom Ruark added a very different interface for reading in layers."

                                 

                                is is related to that interface?

                                 

                                When I look at the doc for FormatRecord (which I did read but I am probably blind, sorry), I cannot figure the how to create a layer mask when loading an image. Just a little hint, as you did last time, will take only 10 sec of your time and make my day. As I said last time, the documentation is well done but I think that it is incomplete in the sense that the big-picture is missing (a few high-level howtos : how to access/create metadata, howto create/read multilayer image, howto create/read masks, ..) There are not that many such recipes but they are required for new developpers to get something done in a reasonable time. Remember that not everybody can be an expert like you and know by heart all the subtle details of the interface.

                                 

                                Please help me! Thank you in advance!

                                 

                                Gilbert

                                • 13. Re: How to Recover Layer Masks From a Format Plugin
                                  Chris Cox Adobe Employee

                                  No, the layer reading interface is, unfortunately, quite different.

                                  You probably need to ask Tom on the developer mailing list about it (I don't think he's reading the forums right now).

                                  • 14. Re: How to Recover Layer Masks From a Format Plugin
                                    G_Soucy Community Member

                                    Ok, thank you. I will try to contact Tom.