Cannot save 32 bit PSD file from 32 bit BaseBitmap



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/03/2010 at 17:04, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11.514 
    Platform:      
    Language(s) :     C++  ;

    ---------
    Hi Everyone,

    I have a plugin that loads a 32 bit tif, but cannot save it as a 32 bit PSD file. Here's the body of the Execute method:

      
    Bool   
    testPluginCmd::Execute(BaseDocument *doc)   
    {   
        String tifPath("~/rawtex/face_tg.tif");   
        String psdPath("~/rawtex/face_tg.psd");   
      
        BaseBitmap *psdSaver = BaseBitmap::Alloc();   
        if (!psdSaver || psdSaver->Init(tifPath) != IMAGE_OK)   
        {   
            GePrint("Fatal: could not load " + tifPath);   
            BaseBitmap::Free(psdSaver);   
            psdSaver = NULL;   
        }   
      
        GePrint("File " + tifPath + " is a");   
        if (psdSaver->GetBt() == 96)   
        {   
            // This prints out, so the file is properly loaded as 32 bits   
            GePrint("     32-bit image");   
        }   
        else if (psdSaver->GetBt() == 48)   
        {   
            GePrint("     16-bit image");   
        }   
        else if (psdSaver->GetBt() == 24)   
        {   
            GePrint("     8-bit image");   
        }   
        else   
        {   
            GePrint("Cannot determine bit depth for loaded tif file: " + tifPath);   
        }   
      
        if (psdSaver && psdSaver->Save(psdPath, FILTER_PSD, NULL, 0) != IMAGE_OK)   
        {   
            GePrint("Fatal: could not convert " + tifPath + " to PSD file");   
        }   
      
        BaseBitmap *psdLoader = BaseBitmap::Alloc();   
        if (!psdLoader || psdLoader->Init(psdPath) != IMAGE_OK)   
        {   
            GePrint("Fatal: could not load " + psdPath);   
            BaseBitmap::Free(psdLoader);   
            psdLoader = NULL;   
        }   
      
        GePrint("File " + psdPath + " is a");   
        if (psdLoader->GetBt() == 96)   
        {   
            GePrint("     32-bit image");   
        }   
        else if (psdLoader->GetBt() == 48)   
        {   
            GePrint("     16-bit image");   
        }   
        else if (psdLoader->GetBt() == 24)   
        {   
            // This prints, the PSD file is 8 bit   
            GePrint("     8-bit image");   
        }   
        else   
        {   
            GePrint("Cannot determine bit depth for loaded psd file: " + psdPath);   
        }   
        BaseBitmap::Free(psdLoader);   
      
        return TRUE;   
    }   
      
    

    When the plugin is executed, the tif file is properly loaded into the BaseBitmap and GetBt() returns 96, which indicates a 32 bit image.

    When the BaseBitmap is saved as FILTER_PSD, the Save method returns IMAGE_OK, so BaseBitmap::Save is successfully writing the image.

    However, when the saved PSD file is loaded, the GetBt method returns 24, indicating an 8 bit image. If the PSD file is loaded into PhotoShop, PhotoShop also reports an 8 bit image.

    What am I donig wrong? Any help greatly appreciated, thanks!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/03/2010 at 20:51, xxxxxxxx wrote:

    ...
    if (psdSaver && psdSaver->Save(psdPath, FILTER_PSD, NULL, 0 ) != IMAGE_OK)
    ...

    What am I donig wrong?

    Well, as loading in Photoshop demonstrated, you saved your file as 8-bit. So the call to the Save method should have been the first suspect. Indeed a quick check in the SDK docs revealed that you likely should set the parameter savebits to something different than 0 ;-)

    I haven't tested it, but this should work:
        if (psdSaver && psdSaver->Save(psdPath, FILTER_PSD, NULL, SAVEBIT_32b**chANNELS ) != IMAGE_OK)

    Hope it helps

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/03/2010 at 20:55, xxxxxxxx wrote:

    Political correct constant names

    This made my day!

    Kabe



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2010 at 10:24, xxxxxxxx wrote:

    Oh I see, I misread the documentation. I read the documentation for the "data" parameter, then saw the section on return values and assumed that was the end of it.

    Thanks!


Log in to reply