On 13/02/2013 at 02:26, xxxxxxxx wrote:
Hi,
I have trouble saving a render to PNG with alpha layer. The resulting PNG image shows no transparency. If I render the model directly from c4d, the resulting image is fine.
I tried to use c4d.SAVEBIT_ALPHA in the Save function but it makes the script crash (see below)
What I am doing wrong?
doc = c4d.documents.GetActiveDocument()
rd = doc.GetActiveRenderData().GetData()
rd[c4d.RDATA_ALPHACHANNEL]= 1
xres = int(round(rd[c4d.RDATA_XRES]))
yres = int(round(rd[c4d.RDATA_YRES]))
bmp = bitmaps.BaseBitmap()
bmp.Init(xres, yres, depth=32)
res = documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL)
if res == c4d.RENDERRESULT_OK:
bitmaps.ShowBitmap(bmp)
bmp.Save(filename, c4d.FILTER_PNG)
# this line makes the script crash at BaseContainer.cpp:1095: bar argument to internal function
#bmp.Save(filename, c4d.FILTER_PNG, c4d.SAVEBIT_ALPHA)
Thanks
Alex