Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Copy texture and save it as png?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 295 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 16/09/2014 at 13:37, xxxxxxxx wrote:

      Hello mates..

      im woundering how i can take a mat/texture (psd) file and copy it and save it as example *.png.
      is this possible with python?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 22/09/2014 at 04:48, xxxxxxxx wrote:

        Hello,

        you can load the texture file into a BaseBitmap[URL-REMOVED] and then save that BaseBitmap as a PNG. The following code assumes you are using a Mmaterial[URL-REMOVED]:

          
             #get the active material  
             activeMaterial = doc.GetActiveMaterial()  
               
              if activeMaterial != None:  
                  colorShader = activeMaterial[c4d.MATERIAL_COLOR_SHADER]  
                  if colorShader != None:  
                      if colorShader.GetType() == c4d.Xbitmap:  
                        
                          # get the texuture file  
                          bitmapPath = colorShader[c4d.BITMAPSHADER_FILENAME]  
                            
                          # load the texture file into the BaseBitmap  
                          theBitmap = bitmaps.BaseBitmap()  
                          theBitmap. _ **InitWith**_ (bitmapPath)  
                            
                          # get the path / filename to save  
                          savePath = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_IMAGES,"Save as PNG")  
                            
                          # save  
                          res = theBitmap. ** _Save_** (savePath, ** _c4d.FILTER_PNG_** )  
                          if res != c4d.IMAGERESULT_OK:  
                              print("Error saving the bitmap!")  
        

        best wishes,
        Sebastian


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 22/09/2014 at 08:29, xxxxxxxx wrote:

          Thank you.

          I was about to start messing around with PIL. seems like i dont need to do that anymore. 🙂

          1 Reply Last reply Reply Quote 0
          • First post
            Last post