2 Replies Latest reply: May 26, 2009 11:37 AM by G_Soucy RSS

    Format Plug-In : problem loading a 4 channels image with CS4

    G_Soucy Community Member

      Hi!

       

      I wrote a format plug-in to support our own in-house file format. That plugin works fine with CS2 but I have some problems with CS4.

       

      Since my plug-in behaves exactly as the "simpleformat" provided with the CS4 SDK, we can center the discussion around that sample project and completely ignore my own plug-in.

       

      In CS2, I can load a 4-channel BMP and save it with the SMP (simpleformat) format. When I load back the SMP file, I recover my 4-channels perfectly.

       

      In CS4, I can also load the same 4-channel BMP and save it in SMP format. However, when I load it back, I lost the 4th channel. I can confirm by looking at the binary contentof the SME file that the 4 channels are there and with no mistake. Is there a reason that would explain why the 4th channel will not load with CS4 but it will with CS2?

       

      I dont know if it is related but I also noticed that the image is loaded as a "Smart Object" in CS4. Other file formats dont seem to do that by default when you just do "open".

       

       

      Thank you!

       

      Gilbert

        • 1. Re: Format Plug-In : problem loading a 4 channels image with CS4
          G_Soucy Community Member

          Some update on that problem: it happens only with CS4.  I tried CS2 and CS3  (version 10.0) and they all work fine (i.e. the demo format plugin in SDK CS4 "simpleformat" can load a 4 channel image no problem). Strange that the CS4 demo program works with all versions except CS4.

           

          I have a feeling that it is related to Smart Objects. Anybody has a clue?

           

          Thanks!

          • 2. Re: Format Plug-In : problem loading a 4 channels image with CS4
            G_Soucy Community Member

            /*****************************************************************************/

            static

             

            void DoReadFinish (void)

            {

                 /* Test the ability to create the file inside a smart object */

                 /* This flag also tells you which menu item was selected */

                 // if openAsSmartObject is already true then you cannot turn it off

                 gFormatRecord->openAsSmartObject = gData->openAsSmartObject;

             

             

                 // every other time we open as smart, that should be confusing enough for a user!

                 gData->openAsSmartObject = !gData->openAsSmartObject;

             

             

                 /* Dispose of the image resource data if it exists. */

                 DisposeImageResources ();

                 WriteScriptParamsOnRead (); // should be different for read/write

                 AddComment (); // write a history comment

            }

             


            Found the problem: the routine DoReadFinish() in SimpleFormat.cpp  ( sample file format plug-in in SDK for CS4) has the routine DoReadFinish() as shown above. I just needed to delete the 2 lines related to smart object. Everything works fine after that. I had overlooked that routine a bit I suppose but those 2 lines do not add much to the undestanding othe plug-in mechanism and they should be deleted from the example IMHO.