Copy texture and save it as png?

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?

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

Hello,

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

  
     #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

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. :)