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()
cm.InitWithBitmap(temp,alpha)
cm.BeginDraw()
#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 )
cm.EndDraw()
#Get bitmap
bmp = cm.GetBitmap().GetClone()
cm.Destroy()
c4d.bitmaps.ShowBitmap(bmp)
if __name__=='__main__':
main()