On 22/10/2015 at 10:59, xxxxxxxx wrote:
They're gone until Monday Niklas.
But maybe this will help.
#This script gets the color data from a BP layer and creates an image from it
#NOTE: GetSelectedTexture() is only supported in R16++
import c4d
def main() :
#Get the selected bp texture(Usually the image in a material)
tex = c4d.modules.bodypaint.PaintTexture.GetSelectedTexture()
texturename = tex.GetFilename()
#Get the active BP layers (the layer tab in the AM)
activelayer = tex.GetActive()
#If the active layer is holding a bitmap image
if activelayer.IsInstanceOf(c4d.OBJECT_PAINTLAYERBMP) == True:
#Convert the layer to an image and store it in memory
#Then get it's size values
bmp = activelayer.ToPaintLayerBmp()
xres = bmp.GetBw()
yres = bmp.GetBh()
size = xres * yres
if size == 0: return
#Get the color mode of the image that's in memory
colorMode = bmp.GetColorMode()
#Store some buffer like data into memory
sq = c4d.storage.ByteSeq(None, size*c4d.COLORBYTES_RGB)
inc = 3
#Read the color data in the image that's currently in memory
#Reminder: This image was gotten from a layer..Which was gotten from a channel in a material
for row in xrange(yres) :
offset = sq.GetOffset(row*(xres*inc))
bmp.GetPixelCnt(0, row, xres, offset, colorMode, c4d.PIXELCNT_0)
#Create a new image based on the color data we just got above
newBitmap = c4d.bitmaps.BaseBitmap()
newBitmap.Init(xres,yres,)
for row in xrange(yres) :
offset = sq.GetOffset(row*(xres*inc))
newBitmap.SetPixelCnt(0, row, xres, offset, inc,colorMode, c4d.PIXELCNT_0)
#Save the image to a file on your HD
filename = c4d.storage.SaveDialog(title="Save Image")
newBitmap.Save(filename,c4d.FILTER_TIF)
if __name__=='__main__':
main()
-ScottA