GeClipMap alpha [SOLVED]

  • On 19/11/2016 at 11:13, xxxxxxxx wrote:

    Hi I would like to import tiff with alpha into a Geclip and still got this alpha but I didn't sucess.
    Thanks in advance here is a little code for testing.

    import c4d
    def main() :
            path = "C:\\Program Files\\MAXON\\CINEMA 4D R17\\plugins\\MyPlugin\\res\\add2.tif"
            #On init un bitmap ave l'image
            temp = c4d.bitmaps.BaseBitmap()
            if temp.InitWith(path)[0] != c4d.IMAGERESULT_OK:
                return False
            size = temp.GetBw()
            alpha = temp.GetInternalChannel()
            #Initialize GeClipMap
            cm = c4d.bitmaps.GeClipMap()
    	#Some test for rewritting alpha
            if alpha:
                for y in xrange(size) :
                    for x in xrange(size) :
                        a = temp.GetAlphaPixel(alpha,x,y)
                        r,g,b = temp.GetPixel(x,y)
                        cm.SetPixelRGBA(x, y, r, g, b,a)    
            #draw a square
            cm.SetDrawMode(c4d.GE_CM_DRAWMODE_BLEND, 255)
            cm.SetColor(150, 150, 150, 150)
            size_pic = cm.GetBw()
            height_pic = cm.GetBh()
            cm.FillRect(0, height_pic - (size/6), size_pic,height_pic )
            #Get bitmap
            bmp = cm.GetBitmap().GetClone()
    if __name__=='__main__':

  • On 21/11/2016 at 03:00, xxxxxxxx wrote:


    the BaseBitmap returned by GetBitmap() does not include the alpha channel (see documentation). Also the Picture Viewer would not display the alpha channel.

    So as far as I can see you have to copy the alpha channel manually.

    # clone bitmap  
    bitmap = clipMap.GetBitmap().GetClone()  
    # add alpha channel  
    alphaChannel = bitmap.AddChannel(True, False)  
    # copy alpha  
    for x in xrange(clipMapWidth) :  
      for y in xrange(clipMapHeight) :  
          r,g,b,a = clipMap.GetPixelRGBA(x,y)  
          bitmap.SetAlphaPixel(alphaChannel, x, y, a)  
    # save bitmap with alpha  
    saveImageFile =,title="Save as PNG")  
    if saveImageFile is not None:  
      bitmap.Save(name = saveImageFile,format = c4d.FILTER_PNG,data = None, savebits =c4d.SAVEBIT_ALPHA)   

    best wishes,

  • On 21/11/2016 at 05:35, xxxxxxxx wrote:

    Thanks you was a missunderstand from me.
    I thinked alpha was not copied into the GeClip.

    Anyway thanks you now all is working as excepted ! :)

Log in to reply